It is currently 10 May 2025, 20:03
   
Text Size

CounterSpell

Moderator: CCGHQ Admins

CounterSpell

Postby nabeshin » 07 Jan 2012, 16:07

When :CounterSpell() call not from hand, it crashes game... Somebody knows something?
User avatar
nabeshin
 
Posts: 207
Joined: 27 Jun 2011, 20:07
Has thanked: 5 times
Been thanked: 31 times

Re: CounterSpell

Postby 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...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Re: CounterSpell

Postby 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".
User avatar
nabeshin
 
Posts: 207
Joined: 27 Jun 2011, 20:07
Has thanked: 5 times
Been thanked: 31 times

Re: CounterSpell

Postby Persee » 14 Feb 2012, 18:27

I have the same problem with Chalice of the Void. No solution can be found ?
User avatar
Persee
 
Posts: 168
Joined: 02 Jun 2011, 08:33
Has thanked: 42 times
Been thanked: 24 times

Re: CounterSpell

Postby 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.
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: CounterSpell

Postby Persee » 15 Feb 2012, 16:22

Frost Titan counter a spell if it's the target of this one.
User avatar
Persee
 
Posts: 168
Joined: 02 Jun 2011, 08:33
Has thanked: 42 times
Been thanked: 24 times

Re: CounterSpell

Postby sadlyblue » 15 Feb 2012, 17:07

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...
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: CounterSpell

Postby 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...
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: CounterSpell

Postby 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...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Re: CounterSpell

Postby 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?
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: CounterSpell

Postby Eglin » 13 Mar 2012, 23:01

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.
User avatar
Eglin
Programmer
 
Posts: 195
Joined: 01 Mar 2012, 14:44
Has thanked: 39 times
Been thanked: 22 times

Re: CounterSpell

Postby 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.
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: CounterSpell

Postby 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
Code: Select all
token:RemoveFromGame()
before the PseudoPlaySpell line. I wonder where the token will go after "pseudo-playing" it.
< 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: 722 times

Re: CounterSpell

Postby 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.
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.
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: CounterSpell

Postby 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...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Next

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 13 guests


Who is online

In total there are 13 users online :: 0 registered, 0 hidden and 13 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 13 guests

Login Form