It is currently 20 Jul 2025, 13:49
   
Text Size

Formal Request Thread

Moderator: CCGHQ Admins

Re: Formal Request Thread

Postby RiiakShiNal » 23 Apr 2014, 14:32

Misplay wrote:Where did you learn to code? Is there a manual or something like that I can read to learn too?!
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.

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.

Misplay wrote:Sometimes, I don't really understand what I'm coding... For example, what does "~= nil" mean?
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).

~= 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
Is used to make sure that (in this case) the return value from the function EffectSource() is not nil (or empty) so that we can use the return later in this block. An example where this is important would be in a "Regenerate" ability in Cudgel Troll for example:
Code: Select all
<RESOLUTION_TIME_ACTION>
  if EffectSource() ~= nil then
    EffectSource():GiveRegeneration()
  end
</RESOLUTION_TIME_ACTION>
Here you need to make sure the EffectSource() (the card) is still valid (still on battlefield) before trying to give it an instance of regeneration (GiveRegeneration()).
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Formal Request Thread

Postby Misplay » 23 Apr 2014, 18:29

Thx a lot for your explanations, it was very clear with the example. :wink:

I'll try to read the Lua 5.2 Reference Manual.
Misplay
 
Posts: 92
Joined: 29 Aug 2013, 08:26
Has thanked: 50 times
Been thanked: 10 times

Re: Formal Request Thread

Postby Luchian » 27 Apr 2014, 19:10

Would really like to know how to do the ability Horsemanship.
Is there a way?
Luchian
 
Posts: 20
Joined: 21 Mar 2014, 20:50
Has thanked: 10 times
Been thanked: 2 times

Re: Formal Request Thread

Postby RiiakShiNal » 27 Apr 2014, 21:23

Luchian wrote:Would really like to know how to do the ability Horsemanship.
Is there a way?
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.

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
Required Abilities to support Characteristics Functions (on card):
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>
Assign Characteristic to card:
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>
Evasion test 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>
And TOKEN_REGISTRATION so it doesn't crash:
Code: Select all
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_CHARACTERISTIC_MANAGER" />
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Formal Request Thread

Postby 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.
Luchian
 
Posts: 20
Joined: 21 Mar 2014, 20:50
Has thanked: 10 times
Been thanked: 2 times

Re: Formal Request Thread

Postby AngelLestat » 02 May 2014, 15:21

Hi, someone know if cards like:

Wonder
Genesis

Are already coded in some mods?

In the mods that I have, I only could find from the Incarnations cards:

Anger
Valor
Glory
Brawn
These last ones, are all made by "The Firemind M"
AngelLestat
 
Posts: 68
Joined: 02 Sep 2012, 23:09
Has thanked: 1 time
Been thanked: 1 time

Re: Formal Request Thread

Postby 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
-----------------------------------------------------------------------
Song of the Day: 46 and 2 (cover)
MC Brodie
 
Posts: 310
Joined: 01 Jun 2013, 00:10
Has thanked: 44 times
Been thanked: 34 times

Re: Formal Request Thread

Postby 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...
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 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!!
Yey! I'm just a little girl who loves MTG! .-.
User avatar
Haku-66
 
Posts: 9
Joined: 22 Jul 2013, 20:43
Has thanked: 2 times
Been thanked: 0 time

Re: Formal Request Thread

Postby Misplay » 03 May 2014, 23:09

AngelLestat wrote:Hi, someone know if cards like:
Genesis
The code for Genesis is on the previous page of this thread (Sumomole).
Misplay
 
Posts: 92
Joined: 29 Aug 2013, 08:26
Has thanked: 50 times
Been thanked: 10 times

Re: Formal Request Thread

Postby 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.
AngelLestat
 
Posts: 68
Joined: 02 Sep 2012, 23:09
Has thanked: 1 time
Been thanked: 1 time

Re: Formal Request Thread

Postby NEMESiS » 04 May 2014, 23:52

Does anyone have Iroas, God of Victory?
User avatar
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

Postby sumomole » 05 May 2014, 10:01

NEMESiS wrote:Does anyone have Iroas, God of Victory?
you could copy the third and fourth ability of Iroas from the following offical cards:
"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
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 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):

| 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>

My guess is <...depends_on_X="1" > in <TARGET> needs to be changed, but can't seem to locate any cards which would help me with that...

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

Postby NEMESiS » 05 May 2014, 20:10

sumomole wrote:
NEMESiS wrote:Does anyone have Iroas, God of Victory?
you could copy the third and fourth ability of Iroas from the following offical cards:
"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
I will give that a try.
User avatar
NEMESiS
 
Posts: 460
Joined: 03 Jan 2013, 04:02
Location: Pools of Becoming
Has thanked: 70 times
Been thanked: 21 times

PreviousNext

Return to 2014

Who is online

Users browsing this forum: No registered users and 10 guests

Main Menu

User Menu

Our Partners


Who is online

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

Login Form