Page 1 of 2

CounterSpell

PostPosted: 07 Jan 2012, 16:07
by nabeshin
When :CounterSpell() call not from hand, it crashes game... Somebody knows something?

Re: CounterSpell

PostPosted: 07 Jan 2012, 16:49
by thefiremind
I can only confirm, that's why I couldn't code Spellstutter Sprite. If you find a solution, let us know.

Re: CounterSpell

PostPosted: 15 Jan 2012, 20:18
by nabeshin
There is at me an idea - it is incorrectly caused function, and from a hand it isn't fatal to a call. It is necessary to look than differs playing "spell ability" from "activated ability".

Re: CounterSpell

PostPosted: 14 Feb 2012, 18:27
by Persee
I have the same problem with Chalice of the Void. No solution can be found ?

Re: CounterSpell

PostPosted: 15 Feb 2012, 10:25
by sadlyblue
Frost titan has the abilitie to counter a spell. Have a look at that code.
Instead of using Counterspell() it sets the target of the spell nil.
Not shure it will work with all spells, since some aren't targetted.

Re: CounterSpell

PostPosted: 15 Feb 2012, 16:22
by Persee
Frost Titan counter a spell if it's the target of this one.

Re: CounterSpell

PostPosted: 15 Feb 2012, 17:07
by sadlyblue
Persee wrote:Frost Titan counter a spell if it's the target of this one.
Looking at the code, it doesn't even counter it, just changes the target of it to nil...
CounterSpell() can only be used within a Spell_Ability. In Spellstutter Sprite its easy to use the spell_ability to counter a spell, if you play it from hand. But if you use any other trick to put into play, it won't work.

I thought of using the trigger comes_into_play to play a counterspell (like isochron scepter). but the problem would be any other permanents that trigger on a spell being played, would trigger on this new one too.

Don't know if its possible, but the other solution i can think, but don't know if its possible to code, is the comes_into_play to trigger and remove the target spell from the stack, then put the card on the graveyard...

Re: CounterSpell

PostPosted: 12 Mar 2012, 17:48
by sadlyblue
Just had an idea looking at some functions in wiki.
Can't we use pseudoplayspell to play a counterspell when Chalice of the Void triggers, or Spellstutter Sprite enters play?

Looking at Show and Tell it uses this function if the chosen card is an aura, because PutInPlay would not choose a target for it. So it might not count as a spell played, and trigger anything that would trigger on playing it.

EDIT:
I've been trying, but doesn't seem possible.
Can't even get it to play a precoded aura. Seems it needs to be an object from the game in progress (graveyard, hand or library).
Tried
Object():GetPlayer():PseudoPlaySpell("SPECTRAL_FLIGHT")
Object():GetPlayer():PseudoPlaySpell("SPECTRAL_FLIGHT_3000030")
It crashes everytime.
Since its not a token, token_registration doesn't work either...

Re: CounterSpell

PostPosted: 13 Mar 2012, 09:28
by thefiremind
Your idea is really good, it's worth to have a deeper look at it. Have you tried with a code similar to the Living weapon mechanic? I have no idea if it works, but you could try...
Code: Select all
    local base_token = MTG():ObtainToken( "CANCEL_242913", Object():GetController() )
    if base_token ~= nil then
      local token = MTG():ObtainTokenFromSpec( base_token:GetSpec(), Object():GetController() )
      if token ~= nil then
        Object():GetPlayer():PseudoPlaySpell( token )
      end
    end

Re: CounterSpell

PostPosted: 13 Mar 2012, 22:21
by sadlyblue
that didn't worked.
it asks for the target, but then does nothing else.
tried with an aura also... same thing.

what is needed is to get the card as a variable.
anyone knows how to do this?

Re: CounterSpell

PostPosted: 13 Mar 2012, 23:01
by Eglin
sadlyblue wrote:that didn't worked.
it asks for the target, but then does nothing else.
tried with an aura also... same thing.

what is needed is to get the card as a variable.
anyone knows how to do this?
Not sure which card or what kind of variable you want, but the token identifier points to the token that's a copy of the cancel spell and I believe you can search for/filter spells on the stack by choosing cards in ZONE_STACK.

Re: CounterSpell

PostPosted: 13 Mar 2012, 23:34
by sadlyblue
The problem is how to get a card, that's not even in the deck.
Something like:
local base_token = MTG():ObtainToken( "CANCEL_242913", Object():GetController() )
But to obtain the card, not a token of the card.

Re: CounterSpell

PostPosted: 13 Mar 2012, 23:42
by thefiremind
Getting cards that aren't in the deck has never been a problem... tokens aren't in the deck, but they work. Same goes for the tokens we use for particular purposes (nabeshin's clone, or my dredge).

I'm not sure, but I think that after initializing a token with the code I wrote above, even before doing anything with it (playing the card or putting it into play or whatever), the token has been already created, it's just in a "nowhere" zone. The problem could be that the game can't handle playing a spell from there.

I'm afraid it won't change a thing, but you could try calling a
Code: Select all
token:RemoveFromGame()
before the PseudoPlaySpell line. I wonder where the token will go after "pseudo-playing" it.

Re: CounterSpell

PostPosted: 15 Mar 2012, 10:27
by sadlyblue
Also didn't work.
I had the idea of PlayForFreeFromAnywhere.
The problem still remains, how to get the card in the code.
In Isochron Scepter, it points to a card previous exiled, and all other cards that use this function, first select the card, one way or the other. In my case i want to play a predefined card.
I was trying with Shock, as proof of concept. And its easier to test.
Code: Select all
local card = "SHOCK_245012"
card:PlayFreeFromAnywhere( Object():GetController() )
didn't worked (didn't crashed the game either, but gave the msg:
Code: Select all
attempt to call method 'PlayFreeFromAnywhere' (a nil value)
I think its because card = "SHOCK_245012" translates into card = string "SHOCK_245012", and not card = Object "SHOCK_245012"
So maybe we need to know how an Object is defined in the game.
The ObtainToken functions does something like that. It gets some charecteristics from the xml and returns an Object. But since its a token, it doesn't fully copy the card.

Re: CounterSpell

PostPosted: 15 Mar 2012, 10:33
by thefiremind
If you want to generate a card from its name, you have to use ObtainToken, there's no other way. I don't think that the problem is being a token, but rather that the game can't properly play a spell out of nowhere.