Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
New MTG Cards and Decks (2010, 2012, 2013, 2014, 2015, Magic Duels)
2014




Formal Request Thread
Moderator: CCGHQ Admins
Re: Formal Request Thread
by RiiakShiNal » 23 Apr 2014, 14:32
Most of us learned to code for DotP by reading the cards that WotC and Stainless coded for us (the official cards) and other posts here on the forums. Some of us though have an actual coding background (from school, work, or both) which can make learning the system and style easier. I am self-taught (started at age 8 with Apple BASIC when I got my first computer, an Apple II+), though I continued my programming education in school and now work in software development.Misplay wrote:Where did you learn to code? Is there a manual or something like that I can read to learn too?!
As for an actual language manual/reference there is the Lua 5.2 Reference Manual (5.2 is the version that DotP uses), but it is more useful as a reference for Lua language features and syntax rather than a way to learn how to code. The reason for this is that in DotP each action and XML block represents a single isolated block of code and we have to use DotP features (rather than Lua features) to pass information between blocks and to do most of the work that a card needs to do.
List of DotP 2014 Functions taken from the executable.
Contents of the DotP 2014 LOL files we were able to decompile.
When you don't understand something and you have already looked around for an answer, that is the time when you should post a question about it on the forums and more often than not someone can provide an answer (not always the answer you are looking for, but an answer nonetheless).Misplay wrote:Sometimes, I don't really understand what I'm coding... For example, what does "~= nil" mean?
~= nil reads literally as "Does not equal nil". The Tilde, "~", is used to denote the logical "Not" in Lua and is most often used in "not equal" comparisons. nil is the Lua equivalent of the C/C++ null keyword which is used to denote that a value has not been set or has been set to the non-value keyword. For example when you first define a variable in Lua with the local keyword it's initial value is nil. So in general a nil check, ~= nil, is used to make sure a variable is set and not empty. For example a common nil check like:
- Code: Select all
if (EffectSource() ~= nil) then
- Code: Select all
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
EffectSource():GiveRegeneration()
end
</RESOLUTION_TIME_ACTION>
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Formal Request Thread
by Misplay » 23 Apr 2014, 18:29
Thx a lot for your explanations, it was very clear with the example.
I'll try to read the Lua 5.2 Reference Manual.

I'll try to read the Lua 5.2 Reference Manual.
Re: Formal Request Thread
by Luchian » 27 Apr 2014, 19:10
Would really like to know how to do the ability Horsemanship.
Is there a way?
Is there a way?
Re: Formal Request Thread
by RiiakShiNal » 27 Apr 2014, 21:23
It is possible to code Horsemanship, but to be completely accurate you would need to create a custom Characteristic (which can be troublesome) and then check for the custom Characteristic.Luchian wrote:Would really like to know how to do the ability Horsemanship.
Is there a way?
Since the engine does not have support for custom Characteristics a while back I created a framework for custom characteristics, Characteristic Functions though it does require my ObjectDC functions to work. Alternately you could create your own implementation which uses my ObjectDC functions (then you would need to manage adding and removing the characteristic yourself at all the appropriate times) or directly using the DuelDataChest() (though then you would need to manage the card linking and adding and removing the characteristic at all appropriate times).
Regardless of what method you choose you will have to assign the custom characteristic to the cards that need it and set up an EVASION_TEST trigger to check for the Characteristic for blocking purposes.
If you decide to use my Characteristics Functions then an example implementation might look like this:
Define Characteristic - MY_CONSTANTS.LOL:
- Code: Select all
MY_CHARACTERISTIC_HORSEMANSHIP = 123456
- Code: Select all
<TRIGGERED_ABILITY replacement_effect="1" active_zone="ZONE_LIBRARY">
<TRIGGER value="BEGINNING_OF_STEP">
return ((MTG():GetStep() == STEP_UPKEEP) and (MTG():GetTurnNumber() == 0))
</TRIGGER>
<RESOLUTION_TIME_ACTION>
RSN_Characteristics_CreateManagers()
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1" active_zone="ZONE_HAND">
<TRIGGER value="BEGINNING_OF_STEP">
return ((MTG():GetStep() == STEP_UPKEEP) and (MTG():GetTurnNumber() == 0))
</TRIGGER>
<RESOLUTION_TIME_ACTION>
RSN_Characteristics_CreateManagers()
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
- Code: Select all
<STATIC_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Horsemanship]]></LOCALISED_TEXT>
<CONTINUOUS_ACTION layer="6">
RSN_Characteristics_Set( EffectSource(), MY_CHARACTERISTIC_HORSEMANSHIP, 1 )
</CONTINUOUS_ACTION></STATIC_ABILITY>
- Code: Select all
<TRIGGERED_ABILITY replacement_effect="1">
<TRIGGER value="EVASION_TEST" simple_qualifier="self" pre_trigger="1">
return RSN_Characteristics_Get( SecondaryObject(), MY_CHARACTERISTIC_HORSEMANSHIP ) == false
</TRIGGER>
</TRIGGERED_ABILITY>
- Code: Select all
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_CHARACTERISTIC_MANAGER" />
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Formal Request Thread
by Luchian » 27 Apr 2014, 23:28
Thanks for the help! I will have to get back to try making a Sun Quan again later.
Maybe you or someone could help with a weird issue I'm having with making Dryad Arbor. I can get the card to function just fine, but it appears in the game with a multicolored card frame. Not a land or green creature. Quite stumped on how to fix this one.
Maybe you or someone could help with a weird issue I'm having with making Dryad Arbor. I can get the card to function just fine, but it appears in the game with a multicolored card frame. Not a land or green creature. Quite stumped on how to fix this one.
Re: Formal Request Thread
by AngelLestat » 02 May 2014, 15:21
- AngelLestat
- Posts: 68
- Joined: 02 Sep 2012, 23:09
- Has thanked: 1 time
- Been thanked: 1 time
Re: Formal Request Thread
by MC Brodie » 02 May 2014, 15:54
Genesis is in one of my mods somewhere. I'll make Wonder sometime after work if nobody else does.
I'm finding some time to start modding again. Don't tell the people in my deck request thread though
. That backlog is astronomical. My free time isn't much though. If all goes well the next month all my time will go towards packing and moving
I'm finding some time to start modding again. Don't tell the people in my deck request thread though

-----------------------------------------------------------------------
Song of the Day: 46 and 2 (cover)
Song of the Day: 46 and 2 (cover)
Re: Formal Request Thread
by thefiremind » 02 May 2014, 18:00
Anybody can try and code Wonder (given the time to do that, of course): just fetch the text with my generator, copy the code from Anger, substitute all occurrences of CHARACTERISTIC_HASTE with CHARACTERISTIC_FLYING, and all occurrences of LAND_TYPE_MOUNTAIN with LAND_TYPE_ISLAND.
< 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: 722 times
Re: Formal Request Thread
by Haku-66 » 03 May 2014, 19:24
Hello guys!
I'd like to request some cards... =$
Borborygmos Enraged and Glimmervoid
And the Urza Lands would be awesome too! (possible to code?) ^w^
Thank you!!
I'd like to request some cards... =$
Borborygmos Enraged and Glimmervoid
And the Urza Lands would be awesome too! (possible to code?) ^w^
Thank you!!
Yey! I'm just a little girl who loves MTG! .-.
Re: Formal Request Thread
by AngelLestat » 04 May 2014, 02:33
ok thanks both, I would search in the mc brody mod.
firemind: I never try to create a card. I would look into that.
firemind: I never try to create a card. I would look into that.
- AngelLestat
- Posts: 68
- Joined: 02 Sep 2012, 23:09
- Has thanked: 1 time
- Been thanked: 1 time
-
NEMESiS - Posts: 460
- Joined: 03 Jan 2013, 04:02
- Location: Pools of Becoming
- Has thanked: 70 times
- Been thanked: 21 times
Re: Formal Request Thread
by sumomole » 05 May 2014, 10:01
you could copy the third and fourth ability of Iroas from the following offical cards:NEMESiS wrote:Does anyone have Iroas, God of Victory?
"Creatures you control" from Marshal's Anthem
"can’t be blocked except by two or more creatures." from Stormblood Berserker
"Prevent all damage" from Dawn Elemental
"that would be dealt to attacking creatures you control." from Dolmen Gate
and you can also find devotion ability from my mod, such as Xenagos, God of Revels
-
sumomole - Programmer
- Posts: 611
- Joined: 07 Jun 2011, 08:34
- Has thanked: 51 times
- Been thanked: 234 times
Re: Formal Request Thread
by tomy0619lee » 05 May 2014, 17:28
Hello everyone,
I recently bought Dotp 2014 and am getting back into coding again.
A question I have is: How do you vary number of targets based on non-mana cost.
Specifically, card Firestorm . What I have so far (repeated localizations removed):
Also, it is not clear to me that the targeting X players/creatures will be mandatory as it should be.
Last thing: should Firestorm be countered if any of X targets are no longer valid? e.g. if X == 3 and one of the targets is sacrificed while Firestorm is on stack, should Firestorm be countered?
Thank you,
Tomy
I recently bought Dotp 2014 and am getting back into coding again.
A question I have is: How do you vary number of targets based on non-mana cost.
Specifically, card Firestorm . What I have so far (repeated localizations removed):
- | Open
- Code: Select all
<UTILITY_ABILITY qualifier="Additional">
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[As an additional cost to cast Firestorm, discard X cards.]]></LOCALISED_TEXT>
<COST type="Discard" definition="0" compartment="1" query_tag="CARD_QUERY_CHOOSE_CARD_TO_DISCARD" item_count_any_number_of="1" />
<COST_DEFINITION id="0">
local filter = ClearFilter()
filter:Add( FE_CARD_INSTANCE, OP_NOT, EffectSource() )
filter:SetZone( ZONE_HAND, EffectController() )
</COST_DEFINITION>
</UTILITY_ABILITY>
<SPELL_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Firestorm deals X damage to each of X target creatures and/or players.]]></LOCALISED_TEXT>
<SFX text="TARGET_FIREBALL_PLAY" />
<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>
<TARGET tag="CARD_QUERY_CHOOSE_DEAL_X_DAMAGE" definition="0" compartment="0" depends_on_X="1">
local num_discard = EffectDC():Get_Targets(1):Count()
MTG():SetTargetCount( num_discard )
</TARGET>
<RESOLUTION_TIME_ACTION>
local num_discard = EffectDC():Get_Targets(1):Count()
local target_array = {}
for i=0,(num_discard - 1) do
local target_creature = EffectDC():Get_Targets(0):Get_CardPtr(i)
local target_player = EffectDC():Get_Targets(0):Get_PlayerPtr(i)
if target_creature ~= nil then
target_array[i] = target_creature
elseif target_player ~= nil then
target_array[i] = target_player
end
end
for i=0,(num_discard - 1) do
if target_array[i] ~= nil then
EffectSourceLKI():DealDamageTo(num_discard, target_array[i])
end
end
</RESOLUTION_TIME_ACTION>
<AI_SIMPLIFIED_TARGETING compartment="0" hint="HINT_ENEMY_ONLY" />
</SPELL_ABILITY>
Also, it is not clear to me that the targeting X players/creatures will be mandatory as it should be.
Last thing: should Firestorm be countered if any of X targets are no longer valid? e.g. if X == 3 and one of the targets is sacrificed while Firestorm is on stack, should Firestorm be countered?
Thank you,
Tomy
- tomy0619lee
- Posts: 13
- Joined: 11 Mar 2013, 03:38
- Has thanked: 3 times
- Been thanked: 1 time
Re: Formal Request Thread
by NEMESiS » 05 May 2014, 20:10
I will give that a try.sumomole wrote:you could copy the third and fourth ability of Iroas from the following offical cards:NEMESiS wrote:Does anyone have Iroas, God of Victory?
"Creatures you control" from Marshal's Anthem
"can’t be blocked except by two or more creatures." from Stormblood Berserker
"Prevent all damage" from Dawn Elemental
"that would be dealt to attacking creatures you control." from Dolmen Gate
and you can also find devotion ability from my mod, such as Xenagos, God of Revels
-
NEMESiS - Posts: 460
- Joined: 03 Jan 2013, 04:02
- Location: Pools of Becoming
- Has thanked: 70 times
- Been thanked: 21 times
Who is online
Users browsing this forum: No registered users and 10 guests