It is currently 18 May 2013, 12:21
   
Text Size

Help with a couple of cards, pretty please?

Moderator: CCGHQ Admins

Help with a couple of cards, pretty please?

Postby Eglin » 05 Mar 2012, 17:58

Hi folks,

Again, I entreat to my knowledgeable peers for a little assistance with a couple of card mechanics. I'd like to implement Gilt-Leaf Archdruid. The card draw is easily borrowed from elsewhere, but I'm having a bit of trouble with the land-stealing mechanic. The Captivating Vampire provides what seems to be a very good starting point, but I'm having trouble modifying it and would very much appreciate some help and guidance. It seems like I need to change the first <play_time_action> to target players instead of a creature to steal - I'm guessing something like this:
Code: Select all
    <PLAY_TIME_ACTION target_choosing="1">
   local count = 0;
   MTG():EffectDataChest():Set_Int(1, count)
    local filter = Object():GetFilter()
    filter:Clear()
    filter:SetOwner( Object():GetPlayer() )
    filter:SetFilterType( FILTER_TYPE_PLAYERS )
    filter:PlayerAntiHint( Object():GetPlayer() )
    Object():GetPlayer():ChooseTargetDC( "CARD_QUERY_CHOOSE_PLAYER", MTG():EffectDataChest():Make_Targets( 0 ))
    </PLAY_TIME_ACTION>
But I'm not sure if the ChooseTargetDC/Make_Targets functionality works for targeting players or just cards. Since my <TARGET_DETERMINATION> section is already used for targeting druids to tap, I'm not sure how else to target the player whose lands I want to steal. It's probably basic, but I still don't understand how the different sections work.

The second problem is in identifying lands within the <continuous action> block. I haven't tried it, but I'm assuming it would be bad to simply do a FilteredCard()::SetController( Object():GetPlayer() ) outside of a layer 2 continuous filter. Can I nest a <FILTER>/<RESOLUTION_TIME_ACTION> pair inside the continuous action block? Even if it were possible, would the card err by stealing lands played in the future? I'm so confused!

If any of you could give me a little guidance on this matter, I'd be very grateful. Thanks!
User avatar
Eglin
Programmer
 
Posts: 185
Joined: 01 Mar 2012, 14:44
Has thanked: 35 times
Been thanked: 19 times

Re: Help with a couple of cards, pretty please?

Postby sadlyblue » 05 Mar 2012, 20:03

Take a look of act of treason it will give you an idea of how to do it. Just don't add the bit of untill end of turn...
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: Help with a couple of cards, pretty please?

Postby Eglin » 05 Mar 2012, 20:26

sadlyblue wrote:Take a look of act of treason it will give you an idea of how to do it. Just don't add the bit of untill end of turn...
Hello again, Sadly! You're becoming a fast friend. Thank you for the suggestion. The Captivating Vampire I referenced above seems to be equally instructive - especially since it teaches us how to tap the untapped creatures. Unfortunately, I haven't been able to figure out how to target a player and take control of /all/ of their lands. Here's what I've got so far:

Code: Select all
    <ACTIVATED_ABILITY layer="2">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Tap seven untapped Druids you control: Gain control of all lands target player controls.]]></LOCALISED_TEXT>
    <AI_AVAILABILITY behaviour="InResponseOrDuringCombat" />
    <TARGET_DETERMINATION>
    local filter = Object():GetFilter()
         
    filter:Clear()
    filter:SetController( Object():GetPlayer() )
    filter:AddSubType( CREATURE_TYPE_DRUID )
    filter:SetZone( ZONE_IN_PLAY )
    filter:AddExtra( FILTER_EXTRA_CREATURE_UNTAPPED )
    filter:NotTargetted()
         
    if Object():GetFilter():CountStopAt( 7 ) &lt; 7 then
      return TARGET_DETERMINATION_NONE
    end
         
    filter:Clear()
    filter:AddCardType( CARD_TYPE_CREATURE )
    filter:SetZone( ZONE_IN_PLAY )
    return TargetBadF()
    </TARGET_DETERMINATION>
    <PLAY_TIME_ACTION target_choosing="1">
    local filter = Object():GetFilter()
    filter:Clear()
    filter:SetOwner( Object():GetPlayer() )
    filter:SetFilterType( FILTER_TYPE_PLAYERS )
    filter:PlayerAntiHint( Object():GetPlayer() )
    Object():GetPlayer():ChooseTargetDC( "CARD_QUERY_CHOOSE_PLAYER", MTG():EffectDataChest():Make_Targets( 0 ))
    </PLAY_TIME_ACTION>
   <COST type="Tap" number="7">
      <PLAYTIME>
     --todo: adjust string
      Object():GetPlayer():ChooseTarget( "CARD_QUERY_TAP_AN_UNTAPPED_DRUID_YOU_CONTROL" )
      </PLAYTIME>
      <TARGET_DETERMINATION>
      local filter = Object():GetFilter()
      filter:Clear()
      filter:SetController( Object():GetPlayer() )
      filter:AddSubType( CREATURE_TYPE_DRUID )
      filter:SetZone( ZONE_IN_PLAY )
      filter:AddExtra( FILTER_EXTRA_CREATURE_UNTAPPED )
      filter:NotTargetted()
      if Object():GetFilter():CountStopAt( 1 ) == 1 then
         return TARGET_DETERMINATION_ALL
      else
         return TARGET_DETERMINATION_NONE
      end
      </TARGET_DETERMINATION></COST>
   <FILTER>
    return ( FilteredCard() ~= nil and
            FilteredCard():GetController() == MTG():EffectDataChest():Get_Targets(0) and
             FilteredCard():GetCardType():Test( CARD_TYPE_LAND ) ~= 0 and
             FilteredCard():GetZone() == ZONE_IN_PLAY
           )
    </FILTER>
    <RESOLUTION_TIME_ACTION>
   if FilteredCard() ~= nil then
      MTG():ObjectDataChest():Set_ProtectedCardPtr( MTG():ObjectDataChest():Int_Get( COMPARTMENT_ID_INT_REGISTER_0 ) + COMPARTMENT_ID_OBJ_REGISTER_0, FilteredCard() )
      MTG():ObjectDataChest():Int_Inc( COMPARTMENT_ID_INT_REGISTER_0 )
   end
    </RESOLUTION_TIME_ACTION>
    <CONTINUOUS_ACTION>
    for i = 0, MTG():ObjectDataChest():Get_Int( COMPARTMENT_ID_INT_REGISTER_0 ) - 1 do
       local land = MTG():ObjectDataChest():Get_ProtectedCardPtr( COMPARTMENT_ID_OBJ_REGISTER_0 + i )
      if land ~= nil then
          land:SetController( Object():GetPlayer() )
      end
    end
    </CONTINUOUS_ACTION>
    <DURATION>
    return false
    </DURATION>
  </ACTIVATED_ABILITY>
After reading theFireMind's suggestion for Sengir Vampire, I decided to try saving a pointer to each of the opponent's lands from within a <filter> block and then to iteratively take control of them from within a <continuous action> block. For whatever reason, this isn't working. I can't rule out syntax errors, but I'm also concerned that maybe it isn't possible to use a <filter> block in this case. Is it only legal to use it within a trigger, or can one use it at any time? I have no idea, and trial-and-error is a very difficult way to learn!
User avatar
Eglin
Programmer
 
Posts: 185
Joined: 01 Mar 2012, 14:44
Has thanked: 35 times
Been thanked: 19 times

Re: Help with a couple of cards, pretty please?

Postby sadlyblue » 05 Mar 2012, 21:58

Have you checked mother.txt, in the duels directory, when you exit the game.
Usually when a card doesn't work properly it outputs to this file the errors.
In my computer, for some reason, this file auto opens when i exit the game and there are some kind of "nonfatal" error. Which is even better, since i don't have to check manually if there's any error :)

Also Dawnglare Invoker has an ability to tap all creatures a player controls. Just change creatures to land, and tap to gain control.
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: Help with a couple of cards, pretty please?

Postby Eglin » 06 Mar 2012, 00:02

sadlyblue wrote:Have you checked mother.txt, in the duels directory, when you exit the game.
Usually when a card doesn't work properly it outputs to this file the errors.
In my computer, for some reason, this file auto opens when i exit the game and there are some kind of "nonfatal" error. Which is even better, since i don't have to check manually if there's any error :)

Also Dawnglare Invoker has an ability to tap all creatures a player controls. Just change creatures to land, and tap to gain control.
I have checked the mother.txt file. It has helped me to find a few errors with things like missing parenthesis, but unfortunately it is not very comprehensive. I must have a card now that's attempting to read a null pointer, but the error log doesn't give any details. It just says, "[] read nil value" or something. I'm not even sure which deck it is in or whether it could be contributing to the crashes. The weirdest bit is that the game /never/ crashes upon opening decks or playing games - it isn't until the game is over and the splash screen / unlock screen comes up that the game crashes. Has that ever happened to you? Do you know of any typical coding errors that can induce such crashes? It's kind of distracting, 'cause I end up making new decks instead of going back to do more testing - haha.

I also saw the Dawnglare Invoker, but I couldn't see any way to incorporate his targeting feature into the spell I wanted to make. I think that if I only needed to tap seven druids or only needed to steal all lands I would be OK - I just haven't been able to figure out how to do them both with one activated ability.

-Cheers
User avatar
Eglin
Programmer
 
Posts: 185
Joined: 01 Mar 2012, 14:44
Has thanked: 35 times
Been thanked: 19 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 2 guests


Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 177 on 10 Oct 2011, 16:37

Users browsing this forum: No registered users and 2 guests

Login Form