Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
CounterSpell
Moderator: CCGHQ Admins
Re: CounterSpell
by sadlyblue » 15 Mar 2012, 11:13
But if that's the problem, shouldn't the RemoveFromGame solve that?
The diference from my code and the Isochron Scepter is the spell being played is a token vs a copy of an exiled card. That's what leads me to conclude the problem is obtaining the token doesn't copy the whole card.
More, what puzzles me is that is lets me make the choices, but it doesn't deal the damage (in the case of the Shock).
Btw:
The diference from my code and the Isochron Scepter is the spell being played is a token vs a copy of an exiled card. That's what leads me to conclude the problem is obtaining the token doesn't copy the whole card.
More, what puzzles me is that is lets me make the choices, but it doesn't deal the damage (in the case of the Shock).
Btw:
- Code: Select all
local card = MTG():ObtainToken( "SHOCK_245012", Object():GetController() )
card:RemoveFromGame()
if card:GetZone() == ZONE_REMOVED_FROM_GAME then
card:PlayFreeFromAnywhere( Object():GetController() )
end
Re: CounterSpell
by thefiremind » 15 Mar 2012, 12:06
I think I understood the problem. A token disappears when it moves to a zone that is not the battlefield. You can choose the targets because it happens before actually playing the spell, but then the game tries to move the token on the stack and it disappears. I'm afraid there's no solution to that.
< 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: 721 times
Re: CounterSpell
by sadlyblue » 15 Mar 2012, 19:01
The only solution would be to load the card counterspell to a variable.
I've tried io, but didn't managed to save any thing. I think those libraries are not loaded, and i don't know how to solve it.
If we were able to save an Object, we could know were the problem is. And would help with other code in the future.
Unfortunately, i'm a beginner coder. Emphasis on beginner.
If anyone, more experience with lua, knows how to do it, pls let me know.
I've tried io, but didn't managed to save any thing. I think those libraries are not loaded, and i don't know how to solve it.
If we were able to save an Object, we could know were the problem is. And would help with other code in the future.
Unfortunately, i'm a beginner coder. Emphasis on beginner.
If anyone, more experience with lua, knows how to do it, pls let me know.
Re: CounterSpell
by sadlyblue » 22 Mar 2012, 10:35
I know it not the ideal but this works.
Not sure it needs the retaindata and set_cardptr. I was trying for so long this ability had the most comment lines ever
This is sort of good news for Spellstutter Sprite, Chalice of the Void, and so on. Not perfect, since the counterspell will trigger as a normal spell would, but is something. Maybe if we get a way not to trigger other cards, kind of a ghost-split-second counter (in case of the sprites and chalice).
- Code: Select all
<TRIGGERED_ABILITY active_zone="any" auto_skip="1">
<TRIGGER value="COMES_INTO_PLAY" simple_qualifier="self" />
<RESOLUTION_TIME_ACTION>
local card = MTG():ObtainToken( "LAVA_SPIKE_12340091", Object():GetController() )
MTG():ObjectDataChest():Set_CardPtr( 1, card )
Object():RetainDataChest()
Object():GetPlayer():CopySpellWithNewTargets( card )
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
Not sure it needs the retaindata and set_cardptr. I was trying for so long this ability had the most comment lines ever
This is sort of good news for Spellstutter Sprite, Chalice of the Void, and so on. Not perfect, since the counterspell will trigger as a normal spell would, but is something. Maybe if we get a way not to trigger other cards, kind of a ghost-split-second counter (in case of the sprites and chalice).
Re: CounterSpell
by Eglin » 22 Mar 2012, 21:14
Great work! This is a fantastic workaround, IMHO.sadlyblue wrote:I know it not the ideal but this works.As the creature entered battlefield it played the Lava Spike. And it will play any spell (like counterspell).
- Code: Select all
<TRIGGERED_ABILITY active_zone="any" auto_skip="1">
<TRIGGER value="COMES_INTO_PLAY" simple_qualifier="self" />
<RESOLUTION_TIME_ACTION>
local card = MTG():ObtainToken( "LAVA_SPIKE_12340091", Object():GetController() )
MTG():ObjectDataChest():Set_CardPtr( 1, card )
Object():RetainDataChest()
Object():GetPlayer():CopySpellWithNewTargets( card )
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
Not sure it needs the retaindata and set_cardptr. I was trying for so long this ability had the most comment lines ever :lol:
This is sort of good news for Spellstutter Sprite, Chalice of the Void, and so on. Not perfect, since the counterspell will trigger as a normal spell would, but is something. Maybe if we get a way not to trigger other cards, kind of a ghost-split-second counter (in case of the sprites and chalice).
Re: CounterSpell
by Eglin » 23 Mar 2012, 06:17
I'm not sure if this is what Nabe was trying to say all along or what, but Spellstutter Sprite can be easily coded by using a <SPELL_ABILTY> instead of a COMES_INTO_PLAY trigger. I've just tested it, and it works flawlessly.nabeshin wrote: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".
Cheers,
Eglin
Re: CounterSpell
by sadlyblue » 23 Mar 2012, 09:31
But if you use another way to put in play, like Aether Vial it wont trigger.
Re: CounterSpell
by Eglin » 23 Mar 2012, 10:04
Ahhhh. That makes sense. Shucks.sadlyblue wrote:But if you use another way to put in play, like Aether Vial it wont trigger.
Re: CounterSpell
by nabeshin » 23 Mar 2012, 15:58
The problem is solved, all can have a rest, recently did Counterbalance and found working option.
P.S. TRIGGER value="ZONECHANGE", if "spell_played" - then you were late.
- Code: Select all
<TRIGGERED_ABILITY internal="1" auto_skip="1" >
<TRIGGER value="ZONECHANGE">
return ( TriggerObject():GetZone() == ZONE_STACK and
TriggerObject():GetPlayer() ~= Object():GetPlayer() and
also not a land)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local card = Object():GetPlayer():Library_GetTop()
if card and card:GetConvertedManaCost() == TriggerObject():GetConvertedManaCost() then
TriggerObject():CounterSpell()
card:GuidedReveal(4,4)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
P.S. TRIGGER value="ZONECHANGE", if "spell_played" - then you were late.
Re: CounterSpell
by sadlyblue » 23 Mar 2012, 19:19
Nice.
Just one thing, will the spell countered this way count as a spell played?
Just one thing, will the spell countered this way count as a spell played?
27 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 22 guests