It is currently 21 Nov 2019, 20:46
   
Text Size

Functions for "Choose a Creature Type"

Moderators: Xander9009, CCGHQ Admins

Re: Functions for "Choose a Creature Type"

Postby alexandreonly » 12 Aug 2012, 02:40

Thanks, Door of Destinies is 100% now. Here in Brazil we are limited to play magic on computers on inside our houses, because we were attacked several times by evangelical christians (they claim that we are doing some kind of ritual). 3 weeks ago i broke the arm of a zealot, he and his friends had planks, ant tried to beat me and my friends, and yesterday another one came with a .38 revolver to threaten us. We are almost in a new dark age here. We can't make our friday night magic anymore :(
alexandreonly
 
Posts: 145
Joined: 04 Jul 2011, 17:27
Has thanked: 0 time
Been thanked: 8 times

Re: Functions for "Choose a Creature Type"

Postby thefiremind » 15 Aug 2012, 09:35

If someone still needs an updated list of all the actual creature types, I found this one:
http://www.wizards.com/Magic/Magazine/A ... rcana/1038
:P
< 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: 717 times

Re: Functions for "Choose a Creature Type"

Postby sadlyblue » 15 Aug 2012, 12:12

It's missing the un-serious creature types... :)
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: Functions for "Choose a Creature Type"

Postby RiiakShiNal » 15 Aug 2012, 14:57

I've updated the first post with 2 more creature types that were missing from the game (completely missing this time): Hyena and Noggle. I also added the Subtype text for them though I could not find (or translate) Noggle in Korean.

Also that article is missing a couple of types that are still in the oracle text (Egg and Townsfolk). They may not be "serious" types, but they are still listed as creature types in the oracle text so I see no reason that they should be excluded.

By comparing types in the game that are missing from the article I also see that type Anemone is no longer used and type Trap is actually used for Instants not Creatures so later I may need to add at least one exception to my code so it doesn't look for Traps.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2130
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 473 times

Re: Functions for "Choose a Creature Type"

Postby thefiremind » 15 Aug 2012, 15:43

I coded Noggle Ransacker without realizing that the Noggle subtype wasn't visible... #-o
My core-fixing WAD is updated with the 2 new subtypes.
< 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: 717 times

Re: Functions for "Choose a Creature Type"

Postby Persee » 07 Sep 2012, 08:15

I tried to code Urza's Incubator but i have a issue.

Code: Select all
  <TRIGGERED_ABILITY forced_skip="1" active_zone="ZONE_TRANSITION">
   <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Bestimme einen Kreaturentyp, wenn Urzas Brutkasten ins Spiel kommt.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Au moment où l'Incubateur d'Urza arrive sur le champ de bataille, choisissez un type de créature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT> 
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <TRIGGER value="ZONECHANGE_TRANSITION" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
   <RESOLUTION_TIME_ACTION>
   local player = EffectController()
   EffectDC():Make_Chest( 0 )
   RSN_FindPlayerCreatureTypesInZone( EffectDC():Get_Chest( 0 ), player, ZONE_LIBRARY )
   local nBestIndex = EffectDC():Get_Chest( 0 ):Int_Get( REGISTER_SELECTION_BEST_TYPE_INDEX )
   EffectDC():Get_Chest( 0 ):Int_Set( REGISTER_SELECTION_SELECTED_INDEX, nBestIndex )
   EffectDC():Int_Set( 10, -1 )
   </RESOLUTION_TIME_ACTION>
   <RESOLUTION_TIME_ACTION repeating="1">
   return RSN_ChooseCreatureTypeFromDC( EffectController(), EffectDC():Get_Chest( 0 ) )
   </RESOLUTION_TIME_ACTION>   
  </TRIGGERED_ABILITY>
  <STATIC_ABILITY filter_zone="ZONE_HAND">
   <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Kreaturenzauber des bestimmten Typs kosten 2 weniger zum Ausspielen.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Les sorts de créature du type choisi coûtent %2 de moins à lancer.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT> 
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <FILTER>
   local chosenType = RSN_GetChosenCreatureType( EffectDC():Get_Chest( 0 ) )
    return (FilteredCard():GetSubType():Test( chosenType ) ~= 0) and
    (FilteredCard():GetPlayer() == EffectController()) and
    (FilteredCard() ~= nil) and
    (FilteredCard():GetZone() == ZONE_HAND)
    </FILTER>   
    <CONTINUOUS_ACTION layer="8">
    if FilteredCard() ~= nil then
       FilteredCard():DecreaseCost( 2 )
    end
    </CONTINUOUS_ACTION>   
  </STATIC_ABILITY>
here's the error : [string "Content\Functions\RSN_CHOOSE_CREATURE_TYPE_FUNCS.LOL [900]"]:163: attempt to index local 'oChest' (a nil value)

here the code line 163 : local nIndex = oChest:Int_Get( REGISTER_SELECTION_SELECTED_INDEX )

This is a part of RSN_GetChosenCreatureType function.

In game, the card works at half: the selection seems to be ok but no reduction cost is applied.

Any idea ?

Thx for help.
User avatar
Persee
 
Posts: 168
Joined: 02 Jun 2011, 08:33
Has thanked: 42 times
Been thanked: 24 times

Re: Functions for "Choose a Creature Type"

Postby RiiakShiNal » 07 Sep 2012, 11:48

That would be because you are using EffectDC() across two different abilities. EffectDC() is only valid inside a single ability (unless passed as a parameter to a delayed trigger). Try using ObjectDC() which persists while the card is in play.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2130
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 473 times

Re: Functions for "Choose a Creature Type"

Postby Persee » 08 Sep 2012, 23:05

Thanks for the tip, it's works. :)

But the message is still in SCRIPT_LOG.TXT : [lua] [string "Content\Functions\RSN_CHOOSE_CREATURE_TYPE_FUNCS.LOL [1128]"]:163: attempt to index local 'oChest' (a nil value)

And I don't know why. :?

Code: Select all
<TRIGGERED_ABILITY forced_skip="1" active_zone="ZONE_TRANSITION">
   <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Bestimme einen Kreaturentyp, wenn Urzas Brutkasten ins Spiel kommt.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Au moment où l'Incubateur d'Urza arrive sur le champ de bataille, choisissez un type de créature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT> 
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <TRIGGER value="ZONECHANGE_TRANSITION" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
   <RESOLUTION_TIME_ACTION>
   local player = EffectController()
   ObjectDC():Make_Chest( 0 )
   RSN_FindPlayerCreatureTypesInZone( ObjectDC():Get_Chest( 0 ), player, ZONE_LIBRARY )
   local nBestIndex = ObjectDC():Get_Chest( 0 ):Int_Get( REGISTER_SELECTION_BEST_TYPE_INDEX )
   ObjectDC():Get_Chest( 0 ):Int_Set( REGISTER_SELECTION_SELECTED_INDEX, nBestIndex )
   ObjectDC():Int_Set( 10, -1 )
   </RESOLUTION_TIME_ACTION>
   <RESOLUTION_TIME_ACTION repeating="1">
   return RSN_ChooseCreatureTypeFromDC( EffectController(), ObjectDC():Get_Chest( 0 ) )
   </RESOLUTION_TIME_ACTION>   
  </TRIGGERED_ABILITY>
  <STATIC_ABILITY filter_zone="ZONE_HAND">
   <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Kreaturenzauber des bestimmten Typs kosten 2 weniger zum Ausspielen.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Les sorts de créature du type choisi coûtent %2 de moins à lancer.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT> 
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <FILTER>
   local chosenType = RSN_GetChosenCreatureType( ObjectDC():Get_Chest( 0 ) )
    return (FilteredCard():GetSubType():Test( chosenType ) ~= 0) and
    (FilteredCard():GetPlayer() == EffectController()) and
    (FilteredCard() ~= nil) and
    (FilteredCard():GetZone() == ZONE_HAND)
    </FILTER>   
    <CONTINUOUS_ACTION layer="8">
    if FilteredCard() ~= nil then
       FilteredCard():DecreaseCost( 2 )
    end
    </CONTINUOUS_ACTION>   
  </STATIC_ABILITY>
Edit : I solved the problem by putting the code in only one ability like you and saving the chosen type in a ObjectDC. No message occurs.

Code: Select all
  <TRIGGERED_ABILITY forced_skip="1" active_zone="ZONE_TRANSITION">
   <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Bestimme einen Kreaturentyp, wenn Urzas Brutkasten ins Spiel kommt.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Au moment où l'Incubateur d'Urza arrive sur le champ de bataille, choisissez un type de créature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT> 
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[As Urza’s Incubator enters the battlefield, choose a creature type.]]></LOCALISED_TEXT>
    <TRIGGER value="ZONECHANGE_TRANSITION" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
   <RESOLUTION_TIME_ACTION>
   local player = EffectController()
   EffectDC():Make_Chest( 0 )
   RSN_FindPlayerCreatureTypesInZone( EffectDC():Get_Chest( 0 ), player, ZONE_LIBRARY )
   local nBestIndex = EffectDC():Get_Chest( 0 ):Int_Get( REGISTER_SELECTION_BEST_TYPE_INDEX )
   EffectDC():Get_Chest( 0 ):Int_Set( REGISTER_SELECTION_SELECTED_INDEX, nBestIndex )
   EffectDC():Int_Set( 10, -1 )
   </RESOLUTION_TIME_ACTION>
   <RESOLUTION_TIME_ACTION repeating="1">
   return RSN_ChooseCreatureTypeFromDC( EffectController(), EffectDC():Get_Chest( 0 ) )
   </RESOLUTION_TIME_ACTION>
   <RESOLUTION_TIME_ACTION>
    local chosenType = RSN_GetChosenCreatureType( EffectDC():Get_Chest( 0 ) )
   ObjectDC():Int_Set(0, chosenType)
   </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
  <STATIC_ABILITY filter_zone="ZONE_HAND">
   <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Kreaturenzauber des bestimmten Typs kosten 2 weniger zum Ausspielen.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Les sorts de créature du type choisi coûtent {2} de moins à lancer.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT> 
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Creature spells of the chosen type cost {2} less to cast.]]></LOCALISED_TEXT>
    <FILTER>
   local chosenType = ObjectDC():Int_Get( 0 )

    return (FilteredCard():GetSubType():Test( chosenType ) ~= 0) and
    (FilteredCard():GetPlayer() == EffectController()) and
    (FilteredCard() ~= nil) and
    (FilteredCard():GetZone() == ZONE_HAND)
    </FILTER>   
    <CONTINUOUS_ACTION layer="8">
    if FilteredCard() ~= nil then
       FilteredCard():DecreaseCost( 2 )
    end
    </CONTINUOUS_ACTION>   
  </STATIC_ABILITY>
Thanks again for your help and your great function =D>
User avatar
Persee
 
Posts: 168
Joined: 02 Jun 2011, 08:33
Has thanked: 42 times
Been thanked: 24 times

Re: Functions for "Choose a Creature Type"

Postby RiiakShiNal » 27 May 2013, 16:07

The files have now been updated to work with the latest updates from WotC.

Changes are to:
  • RSN_CHOOSE_CREATURE_TYPE_FUNCS.LOL - to update the constants
  • CREATURE_TYPES.TXT - to correct the order of SURRAKAR to match with WotC's version.
  • CREATURE_TYPE_TEXT_8192.XML - To make the text match with the new constant values.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2130
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 473 times

Previous

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 3 guests


Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 10 minutes)
Most users ever online was 553 on 18 Nov 2019, 23:05

Users browsing this forum: No registered users and 3 guests

Login Form