Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



CounterSpell
Moderator: CCGHQ Admins
CounterSpell
by nabeshin » 07 Jan 2012, 16:07
When :CounterSpell() call not from hand, it crashes game... Somebody knows something?
Re: CounterSpell
by thefiremind » 07 Jan 2012, 16:49
I can only confirm, that's why I couldn't code Spellstutter Sprite. If you find a solution, let us know.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: CounterSpell
by nabeshin » 15 Jan 2012, 20:18
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
by Persee » 14 Feb 2012, 18:27
I have the same problem with Chalice of the Void. No solution can be found ?
Re: CounterSpell
by sadlyblue » 15 Feb 2012, 10:25
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.
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
by Persee » 15 Feb 2012, 16:22
Frost Titan counter a spell if it's the target of this one.
Re: CounterSpell
by sadlyblue » 15 Feb 2012, 17:07
Looking at the code, it doesn't even counter it, just changes the target of it to nil...Persee wrote:Frost Titan counter a spell if it's the target of this one.
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
by sadlyblue » 12 Mar 2012, 17:48
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...
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
by thefiremind » 13 Mar 2012, 09:28
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
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: CounterSpell
by sadlyblue » 13 Mar 2012, 22:21
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?
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
by Eglin » 13 Mar 2012, 23:01
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.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?
Re: CounterSpell
by sadlyblue » 13 Mar 2012, 23:34
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.
Something like:
local base_token = MTG():ObtainToken( "CANCEL_242913", Object():GetController() )
But to obtain the card, not a token of the card.
Re: CounterSpell
by thefiremind » 13 Mar 2012, 23:42
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
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()
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: CounterSpell
by sadlyblue » 15 Mar 2012, 10:27
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.
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.
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() )
- Code: Select all
attempt to call method 'PlayFreeFromAnywhere' (a nil value)
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
by thefiremind » 15 Mar 2012, 10:33
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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
27 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 18 guests