It is currently 19 May 2013, 04:45
   
Text Size

More Bug Fixing of Core Cards

Moderator: CCGHQ Admins

More Bug Fixing of Core Cards

Postby Jace11 » 12 Apr 2012, 18:51

Still working at fixing some cards.

Attached is a zip of Core and DLC cards I've fixed and tested so far. I can't upload the the wads really cause that would be distributing the DLC for free, but they can be installed into existing DLC wads if you follow these instructions... http://www.slightlymagic.net/forum/viewtopic.php?f=63&t=6820#p86897

So, now stuck on captivating vampire, specifically its ability to control an opponents card if you tap 5 other vampires. The bug people have been reported with this is that it can target cards with protection from black and take control of them. This obviously shouldn't be. Why the standard protection scripts do not work for this I don't know, maybe because it is not a spell, damage, instant etc, it is an ability that can be activated without tapping the captivating vamp.

Problem code:

Code: Select all
   local filter = Object():GetFilter()
    filter:Clear()
    filter:AddCardType( CARD_TYPE_CREATURE )
    filter:SetZone( ZONE_IN_PLAY )
    filter:PlayerAntiHint( Object():GetPlayer() )
    Object():GetPlayer():ChooseTargetDC( "CARD_QUERY_CHOOSE_CREATURE_TO_GAIN_CONTROL", MTG():EffectDataChest():Make_Targets( 1 ))
It shouldn't be necessary, but I think it needs an extra filter for protection from black here. As there is not a standard filter for this, can you do a filtered card check first then apply the above filters?

So I guess the filter would be to not allow targeting of a card with protection from black
so I tried to think of a card that might have a filter similar to that needed here...


Brave the Elements seems to perform a test for colour white first before it applies effects, I guess something similar would work where a test is performed for protection from black? then its a case of setting the true / false correctly and combining this with the other filters?


Code: Select all
    <FILTER>
    return (FilteredCard() ~= nil and
    FilteredCard():GetCardType():Test( CARD_TYPE_CREATURE ) ~= 0 and
    FilteredCard():GetZone() == ZONE_IN_PLAY and
    FilteredCard():GetController() == Object():GetController() and
    FilteredCard():GetColour():Test( COLOUR_WHITE ) ~= 0)
    </FILTER>
Sorry I'm so bad at LUA, I'm learning some as I go along, and looking at other cards for ideas / fixes, but I'm stuck again...
Attachments
Fixed Cards.zip
(9.85 KiB) Downloaded 27 times
Jace11
 
Posts: 13
Joined: 27 Jan 2011, 05:19
Has thanked: 3 times
Been thanked: 0 time

Re: More Bug Fixing of Core Cards

Postby Eglin » 12 Apr 2012, 22:35

Before you pull your hair out working up a solution, have you been able to duplicate the problem?

There's a list of all the known filters here, but I don't think there's anything that would filter for pfb. In fact, I can't think of any way to query a card's protections under any circumstances.

It has been a while since I've looked at the Cultivating Vampire, but maybe his target determination block is used for targeting the five vampires to tap instead of the creature to steal. If that's the case, you could try swapping the two. Otherwise, it's a fundamental flaw with the way the protection works - and I don't think you'd be able to fix it with LUA alone.

This is an interesting problem, and you're doing great work. Please let us know what you come up with.

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

Re: More Bug Fixing of Core Cards

Postby Jace11 » 13 Apr 2012, 01:55

Thanks for the table... it was needed.

I think maybe I have an idea but I'll have to think about it a bit more, I could use a flip based on badges for colour protection?

I havent tested for this bug actually... I have tested all the other fixes though, making custom decks etc just to test them.

Anyhow, I hate the buggy cards. The biggest bugs people talk about is hexproof preventing forced sacrifices. This is in call to the grave and woebringer daemon, they both lacked a filter:NotTargetted(). Souls of the faithless would activate its abilty if it took damage outside combat, this was an easy fix,- just copied the trigger from the other two walls in the Dark heavens deck (that are very similar) to ensure its activated by combat damage only. Tested this using instants and prodigal pyro etc.. only combat damage triggers it now.

Lord of the Unreal was bugged in 2HG games and conferred hexproof on teammates illusions - (I used another card that does the same for artifacts). I have checked this fix using custom decks against two AI realms and in reverse (Player + AI realms) and it no longer gives teamates illusions hexproof, while as an ally, i can still target them.

Treefolk harbinger was not shuffling the deck before you placed top card back onto library. Just added a shuffle step. So you could play two in a row and line up your next two cards on the library. I have checked it with the fix and it does now shuffle.
Jace11
 
Posts: 13
Joined: 27 Jan 2011, 05:19
Has thanked: 3 times
Been thanked: 0 time

Re: More Bug Fixing of Core Cards

Postby thefiremind » 14 Apr 2012, 15:29

There's something I never noticed until now, and I was wondering if it's a bug.

Faceless Butcher, Journey to Nowhere and Oblivion Ring exile their targets in a PLAY_TIME_ACTION. This means nobody can answer to the trigger before it does its thing. Is this behaviour right or not? (And if it's right, why?)
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
User avatar
thefiremind
Programmer
 
Posts: 1630
Joined: 07 Nov 2011, 10:55
Has thanked: 60 times
Been thanked: 357 times

Re: More Bug Fixing of Core Cards

Postby Jace11 » 14 Apr 2012, 17:08

Hmm, 2 similar bugs have been reported with red cards in the core / dlc files, one is grim lavamancer and the other is slagstorm. They both require a choice to be made (cards to exile from graveyard / damage player or opponent) but then there is no indication of which choice has been made, the damage is applied and cannot be respsoned to. I was thinking of looking at these next.. need a visible targetting step for other players to respond to.

As for the captivating vamp bug, I just made decks to test the reported targeting bug, and it's not true, the card is fine and prevented me from targetting white knights etc... what they might have meant when they reported this, is if you target a card and then a protection from black effect is placed on the target by a spell or something, it still targets it... not sure.. and that is very difficult to test.
Jace11
 
Posts: 13
Joined: 27 Jan 2011, 05:19
Has thanked: 3 times
Been thanked: 0 time

Re: More Bug Fixing of Core Cards

Postby Eglin » 14 Apr 2012, 17:08

thefiremind wrote:There's something I never noticed until now, and I was wondering if it's a bug.

Faceless Butcher, Journey to Nowhere and Oblivion Ring exile their targets in a PLAY_TIME_ACTION. This means nobody can answer to the trigger before it does its thing. Is this behaviour right or not? (And if it's right, why?)
These effects should all go to the stack. It actually leads to some really amusing side-effects, because the second effect can resolve before the first under some circumstances (i.e., o-ring is hit w/ naturalize before first effect resolves). That said, the O-ring and Journey that I have both correctly determine a target at play-time and exile at resolution.
User avatar
Eglin
Programmer
 
Posts: 185
Joined: 01 Mar 2012, 14:44
Has thanked: 35 times
Been thanked: 19 times

Re: More Bug Fixing of Core Cards

Postby Eglin » 14 Apr 2012, 17:19

Jace11 wrote:Hmm, 2 similar bugs have been reported with red cards in the core / dlc files, one is grim lavamancer and the other is slagstorm. They both require a choice to be made (cards to exile from graveyard / damage player or opponent) but then there is no indication of which choice has been made, the damage is applied and cannot be respsoned to. I was thinking of looking at these next.. need a visible targetting step for other players to respond to.
Both of these look OK to me. I've never noticed a problem, and they both deal their damage in the resolution section.

Jace11 wrote:As for the captivating vamp bug, I just made decks to test the reported targeting bug, and it's not true, the card is fine and prevented me from targetting white knights etc... what they might have meant when they reported this, is if you target a card and then a protection from black effect is placed on the target by a spell or something, it still targets it... not sure.. and that is very difficult to test.
Ah, I see. I had a similar problem with Vines of Vastwood. The check to determine whether or not a card is a valid target happens before Vines is cast as a response, and it's a problem. I have considered adding, in this case, a filter that grants protection from spells that opponents play, because I assumed that protection worked where shroud/hexproof/etc did not. If what you're saying is correct, then a protection filter wouldn't help - although it leaves me wondering how cards like Mother of Runes correctly grant protection as an interrupt. That's worth looking into. It may also be possible to use a <filter> block to iterate over spells on the stack and set their targets to nil if they point to the card we're interested in. If you make any headway, I'd love to hear about it. Good luck!

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

Re: More Bug Fixing of Core Cards

Postby thefiremind » 14 Apr 2012, 18:06

Eglin wrote:These effects should all go to the stack. It actually leads to some really amusing side-effects, because the second effect can resolve before the first under some circumstances (i.e., o-ring is hit w/ naturalize before first effect resolves). That said, the O-ring and Journey that I have both correctly determine a target at play-time and exile at resolution.
OK, thanks for the clarification. I wanted to be sure that my freshly coded Admonition Angel works as intended. Using a PLAY_TIME_ACTION leads to unexpected results indeed: I made one Admonition Angel exile another one, and the card exiled by the first one also returned in play... but it was the second angel who left play! :shock: With a RESOLUTION_TIME_ACTION this bug doesn't happen. :)

Jace11 wrote:Hmm, 2 similar bugs have been reported with red cards in the core / dlc files, one is grim lavamancer and the other is slagstorm. They both require a choice to be made (cards to exile from graveyard / damage player or opponent) but then there is no indication of which choice has been made, the damage is applied and cannot be respsoned to. I was thinking of looking at these next.. need a visible targetting step for other players to respond to.
A basic rule of Magic is that you can't respond to something that's written before ":" because that is a cost. So you can't empty the opponent's graveyard when he already declared that he wants to activate Grim Lavamancer: the cost has been already paid when you have the priority. No bugs there. :wink:
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
User avatar
thefiremind
Programmer
 
Posts: 1630
Joined: 07 Nov 2011, 10:55
Has thanked: 60 times
Been thanked: 357 times

Re: More Bug Fixing of Core Cards

Postby Jace11 » 15 Apr 2012, 01:58

Good info, I'm just going through a list of bugged cards on the wizards forums, it won't be the first or last time I read a bug report that actually isnt a bug and is working as designed.
Jace11
 
Posts: 13
Joined: 27 Jan 2011, 05:19
Has thanked: 3 times
Been thanked: 0 time

Re: More Bug Fixing of Core Cards

Postby Jace11 » 20 Apr 2012, 14:47

MOTHER.txt errors?

Are all these real bugs? I get mother error messages with some cards that appear to be working as designed. Path to Exile and Living Death both routinely give errors in this file, but appear to resolve ok.

eg. [lua] [string "LIVING_DEATH_210138_TITLE (RESOLUTION_TIME_ACTION) [1428F960]"]:3: attempt to index a nil value
[lua]

Is this a "potential" bug, i.e is there a problem with the lua scripting that could cause a problem under certain circumstances but be fine most of the time? Its pretty rare for the game to output any errors, so I suspect there is a fault in the script, though perhaps not a fatal one.


Path to Exile Resolution:
Code: Select all
   <RESOLUTION_TIME_ACTION>
    MTG():EffectDataChest():Set_PlayerPtr(1, Object():GetTargetCard():GetPlayer())
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    if (MTG():EffectDataChest():Get_Targets( 0 ) ~= nil) then
       local target1 = MTG():EffectDataChest():Get_Targets( 0 ):Get_NthCardPtr( 0 )
       if target1 ~= nil and target1:GetZone() == ZONE_IN_PLAY then
          target1:RemoveFromGame()
       end
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local player = MTG():EffectDataChest():Get_PlayerPtr(1)
    local filter = Object():GetFilter()
    if player ~= nil then
       
            filter:Clear()
          filter:NotTargetted()
            filter:SetPlayer( player )
          filter:AddCardType( CARD_TYPE_LAND )
          filter:AddSupertype( SUPERTYPE_BASIC )
            filter:SetZone( ZONE_LIBRARY )
            filter:PlayerHint( player )
           
       local targetDC = MTG():EffectDataChest():Get_Targets(2)
       if targetDC == nil then
         targetDC = MTG():EffectDataChest():Make_Targets(2)
       end
       player:ChooseTargetDC( "CARD_QUERY_CHOOSE_LAND_TO_PUT_ONTO_BATTLEFIELD", targetDC )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local player = MTG():EffectDataChest():Get_PlayerPtr(1)
    if player ~= nil then
       local targetDC = MTG():EffectDataChest():Get_Targets(2)
       if targetDC ~= nil then
          local target_card = targetDC:Get_CardPtr(0)
          if target_card ~= nil then
             target_card:GuidedReveal( ZONE_LIBRARY, ZONE_IN_PLAY )
             target_card:PutIntoPlayTapped( player )
          end
       end
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local player = MTG():EffectDataChest():Get_PlayerPtr(1)
    if player ~= nil then
      player:ShuffleLibrary()
    end
    </RESOLUTION_TIME_ACTION>
Living Death
Code: Select all
    <RESOLUTION_TIME_ACTION>
    local total_creatures = 0
    local total_grave_size =0
    local i = 0
    local j = 0
    local k = 0
    local filter = Object():GetFilter()
    local num_players = MTG():GetNumberOfPlayers()
    filter:Clear()
    filter:SetZone( ZONE_GRAVEYARD )
    filter:AddCardType( CARD_TYPE_CREATURE )
    filter:NotTargetted()
    total_creatures = filter:Count()
    for i=0,(num_players-1) do
      local player = MTG():GetNthPlayer(i)
       filter:Clear()
       filter:SetZone( ZONE_GRAVEYARD )
       filter:NotTargetted()
       filter:SetPlayer( player )
       total_grave_size = filter:Count()
       for k=0,(total_grave_size-1) do
          local card = player:Graveyard_GetNth(k)
          if card:GetCardType():Test( CARD_TYPE_CREATURE ) ~= 0 then
             MTG():ObjectDataChest():Set_ProtectedCardPtr( j, card )
             j = j+1
          end
       end
    end
    </RESOLUTION_TIME_ACTION>
Also I might start updating some cards from DotP 2009 for DotP 2012. I miss a few of the cards from the older game and feel some may be useful for strengthening the weaker decks in DotP2012.

Here is Kamahl Pit fighter, all languages except japanese :(
Attachments
Kamahl Pit Fighter.zip
(105.24 KiB) Downloaded 13 times
Jace11
 
Posts: 13
Joined: 27 Jan 2011, 05:19
Has thanked: 3 times
Been thanked: 0 time

Re: More Bug Fixing of Core Cards

Postby thefiremind » 20 Apr 2012, 15:17

MOTHER.TXT is really useful to understand what's wrong. It keeps track of fatal exceptions only, and it's a bit vague on the position of the error, but if you learn how to read it, you have some more help on debugging cards.

Let's take your example:
Code: Select all
[lua] [string "LIVING_DEATH_210138_TITLE (RESOLUTION_TIME_ACTION) [1428F960]"]:3: attempt to index a nil value
It says that the card Living Death generated an exception on the 3rd line of a RESOLUTION_TIME_ACTION. The lines are counted starting from the <..._ACTION> block (probably because the game adds a line of code before interpreting). With this information I have been able to understand what caused the exception. Note that it's not in the resolution you posted. Cards can have lots of blocks and MOTHER.TXT doesn't specify which one you should investigate. But at least, you have to look at 3rd lines only. :wink:
Code: Select all
  <SPELL_ABILITY zone="any">
1-> <RESOLUTION_TIME_ACTION>
2-> for i=0,250 do
3-> MTG():ObjectDataChest():Get_ProtectedCardPtr(i):PutIntoPlay( MTG():ObjectDataChest():Get_ProtectedCardPtr(i):GetPlayer() ) 
    end
    </RESOLUTION_TIME_ACTION>
    <SFX text="GLOBAL_DEATH_SPELL_RESOLVED_PLAY" />
  </SPELL_ABILITY>
This is pure coding laziness... the coder didn't want to keep track of how many pointers are saved, and iterated for a large number of times. Of course you'll never have 251 cards to put into play, and the unused pointers generate that exception.
Easy fix:
Code: Select all
  <SPELL_ABILITY zone="any">
    <RESOLUTION_TIME_ACTION>
    for i=0,250 do
      local card = MTG():ObjectDataChest():Get_ProtectedCardPtr(i)
      if card ~= nil then
        card:PutIntoPlay( card:GetPlayer() )
      end 
    end
    </RESOLUTION_TIME_ACTION>
    <SFX text="GLOBAL_DEATH_SPELL_RESOLVED_PLAY" />
  </SPELL_ABILITY>
Edit the last ability like this, and the error should disappear.

If you post the MOTHER.TXT entry for Path to Exile, I can try to understand what's wrong there, too.
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
User avatar
thefiremind
Programmer
 
Posts: 1630
Joined: 07 Nov 2011, 10:55
Has thanked: 60 times
Been thanked: 357 times

Re: More Bug Fixing of Core Cards

Postby pcastellazzi » 25 Apr 2012, 08:03

I fixed a bunch of core cards too.

-- call to the grave (it now work with hexprof/shroud/protection from black)
-- lord of the undead (it now affect all zombies, not only the ones you control)
-- living death (nil exception)
-- cemetery reaper (nil exception)
-- beast within (nil exception)
-- quest for the gravelord (it now stop adding counter when on the graveyard)

I am planning on creating a repository for all this fixes with a dlc for them. Do you think it is a good idea? Are you willing to colaborate?
Attachments
fixes.zip
Core card fixes.
(12.41 KiB) Downloaded 19 times
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 182
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 10 times
Been thanked: 29 times

Re: More Bug Fixing of Core Cards

Postby sadlyblue » 25 Apr 2012, 08:14

The repository is a good idea.
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: More Bug Fixing of Core Cards

Postby Jace11 » 01 May 2012, 00:31

Absolutely a good idea!

A repository for fixed cards is a great idea

I wonder if, when dotp2013 or whatever it is comes out this year, we can add cards from that easily. They changed the xml format between 2009 and 2012, but because of the short turn around, there is a good probability the next game will use the same format.
Jace11
 
Posts: 13
Joined: 27 Jan 2011, 05:19
Has thanked: 3 times
Been thanked: 0 time

Re: More Bug Fixing of Core Cards

Postby thefiremind » 01 May 2012, 11:00

Jace11 wrote:I wonder if, when dotp2013 or whatever it is comes out this year, we can add cards from that easily. They changed the xml format between 2009 and 2012, but because of the short turn around, there is a good probability the next game will use the same format.
We all hope so! :D

About the repository, if it's just for the fixed cards, I'm all for it. If we want to extend it to new cards coded by the modders, I'm not for it nor against it... the thing is, when there's a complicated card to code, many modders could come up with different solutions equally right, so it would be a pity to choose one and forget the rest. We could keep all the versions of the same card, but this would be a bit against the idea of repository... so, I don't know... :|
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
User avatar
thefiremind
Programmer
 
Posts: 1630
Joined: 07 Nov 2011, 10:55
Has thanked: 60 times
Been thanked: 357 times

Next

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