Page 6 of 7

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 19 May 2011, 20:40
by slapshot5
Hellfish wrote:So with a few mods to AF_CounterMagic and a very barebones AF_DelayedTrigger I was able to get this seemingly working:
Code: Select all
Name:Mana Drain
ManaCost:U U
Types:Instant
Text:no text
A:SP$Counter | Cost$ U U | TargetType$ Spell | RememberTargets$ True | ForgetOtherTargets$ True | ValidTgts$ Card | SubAbility$SVar=DBDelTrig | SpellDescription$ Counter target spell. At the beginning of your next main phase, add X to your mana pool, where X is that spell's converted mana cost.
SVar:DBDelTrig:DB$DelayedTrigger | Mode$ Phase | Phase$ Main1,Main2 | ValidPlayer$ You | Execute$ AddMana | TriggerDescription$ CARDNAME - At the beginning of your next main phase, add X to your mana pool, where X is the countered spell's converted mana cost.
SVar:AddMana:AB$Mana | Cost$ 0 | Produced$ 1 | Amount$ X
SVar:X:Remembered$CardManaCost
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/mana_drain.jpg
SetInfo:LEG|Uncommon|http://magiccards.info/scans/en/lg/65.jpg
End
Thoughts?

The AF_DelayedTrigger I have now only provides for subabilities and just returns false for any AI checks.
Is this stuff checked in that I can test? Mana Drain is in one of my main decks, and I'd be more than happy to do some testing if I could.

-slapshot5

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 19 May 2011, 20:57
by Hellfish
Alright, I trimmed some stuff out so that no card is actually affected yet. If you take r8852 and comment out Mana Drain's code in CF_Instants and paste the script I posted in it's txt file you should be able to try it.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 27 May 2011, 20:02
by jeffwadsworth
Hellfish wrote:So with a few mods to AF_CounterMagic and a very barebones AF_DelayedTrigger I was able to get this seemingly working:
Code: Select all
Name:Mana Drain
ManaCost:U U
Types:Instant
Text:no text
A:SP$Counter | Cost$ U U | TargetType$ Spell | RememberTargets$ True | ForgetOtherTargets$ True | ValidTgts$ Card | SubAbility$SVar=DBDelTrig | SpellDescription$ Counter target spell. At the beginning of your next main phase, add X to your mana pool, where X is that spell's converted mana cost.
SVar:DBDelTrig:DB$DelayedTrigger | Mode$ Phase | Phase$ Main1,Main2 | ValidPlayer$ You | Execute$ AddMana | TriggerDescription$ CARDNAME - At the beginning of your next main phase, add X to your mana pool, where X is the countered spell's converted mana cost.
SVar:AddMana:AB$Mana | Cost$ 0 | Produced$ 1 | Amount$ X
SVar:X:Remembered$CardManaCost
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/mana_drain.jpg
SetInfo:LEG|Uncommon|http://magiccards.info/scans/en/lg/65.jpg
End
Thoughts?

The AF_DelayedTrigger I have now only provides for subabilities and just returns false for any AI checks.
It works perfectly fine here. Thanks.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 31 May 2011, 03:20
by friarsol
Looks like AEther Membrane 's delayed trigger hit the stack in game 2, when it triggered in game 1. Probably just need to be clearing a list out somewhere during End Game cleanup.

Also, with Flameblast Dragon it seems like state effects aren't checked after its SA resolves, because the AI can still block with creatures that should be dead from the Trigger before they actually die.

Some clarification: it looks like the costs are paid for Flameblasts trigger, but the SA never actually hits the Stack until CombatDamage resolves.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 31 May 2011, 06:04
by Hellfish
AEther Membrane should be fixed.

Flameblast Dragon I don't quite know what it's doing. State effects *are* checked when a spellability finishes resolving,AFAICT.

EDIT:Found and fixed the problem.StateEffects were checked when a spellability finishes resolving BUT the actual damagedealing ability of the dragons trigger does not resolve via the usual means, only it's wrapping ability does.Currently the wrapped abilities of triggers get their resolve method called directly from a piece of specialized SpellAbility_Restriction code. For the time being, I added a state effects check there, and a TODO in my list to, in the immortal words of Strong Bad, DO-SUM-BOW-DIS. :mrgreen:

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 31 May 2011, 12:16
by friarsol
Ah good.

Ideally, state based effects should be checked after each SA finishes resolving completely and at the beginning of Phases/Steps, so it doesn't need to appear 40 times throughout the code. Is there some part of the trigger system that is incapatable with that idea?

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 01 Jun 2011, 10:24
by Sloth
friarsol wrote:Ah good.

Ideally, state based effects should be checked after each SA finishes resolving completely and at the beginning of Phases/Steps, so it doesn't need to appear 40 times throughout the code. Is there some part of the trigger system that is incapatable with that idea?
Actually they have to be checked at other times too:
- Card draw (Akki Underling)
- Add Mana to Manapool (Omnath, Locus of Mana)
- Something becomes tapped (Maraxus of Keld)
- Counters get removed

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 01 Jun 2011, 12:18
by friarsol
Sloth wrote:
friarsol wrote:Ah good.

Ideally, state based effects should be checked after each SA finishes resolving completely and at the beginning of Phases/Steps, so it doesn't need to appear 40 times throughout the code. Is there some part of the trigger system that is incapatable with that idea?
Actually they have to be checked at other times too:
- Card draw (Akki Underling)
- Add Mana to Manapool (Omnath, Locus of Mana)
- Something becomes tapped (Maraxus of Keld)
- Counters get removed
Not all Card Draw though right? Just the State based effect at the beginning of your turn?
Paying costs of non-mana abilities (the last three) shouldn't check state based effects though. Only paying costs of mana abilities should check afterwards (since they don't use the stack).

So really we have:
Phase based effects (card draw/all combat damage is dealt), After an SA resolves, After an SA (and all corresponding triggers) is added to the stack, and after a Mana Ability is activated. Or am I missing some other hidden times?

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 01 Jun 2011, 12:59
by Sloth
friarsol wrote:So really we have:
Phase based effects (card draw/all combat damage is dealt), After an SA resolves, After an SA (and all corresponding triggers) is added to the stack, and after a Mana Ability is activated. Or am I missing some other hidden times?
This should cover everything (ignoring some obscure corner cases such as Circling Vultures).

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 05 Jun 2011, 19:20
by Hellfish
friarsol wrote:Ah good.

Ideally, state based effects should be checked after each SA finishes resolving completely and at the beginning of Phases/Steps, so it doesn't need to appear 40 times throughout the code. Is there some part of the trigger system that is incapatable with that idea?
Yes, triggered abilities use a modified version of GameAction.playSpellAbility that lets the wrapped ability skip the stack and still use the standard targeting functions that comes with playSpellAbility. It should skip the stack since the wrapping spellability was there already but any targeting/cost payment is done by that function.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 12 Jun 2011, 20:39
by friarsol
Hellfish,

After I commit my Multi-targeting fix sometime soon, the next goal is to use this same class for storing TriggeredObjects. Do you know why the TriggeringObject is stored on the Card and not the Trigger/SA? Do some TriggeredObjects need to remain on the Card after the Trigger finishes resolving?

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 14 Jun 2011, 10:23
by Hellfish
Yeah, I seem to remember there were some cases like that. I still havn't got internet in my new place but once I do I'll be on this first thing, and contribute regularly again, something public library computers are not good for. >_>

EDIT: Welp, now I remembered why I put TriggeringObjects in Card instead of anywhere else: So that they'd persist long enough for delayed triggers to make use of them. I don't know if there are any cards that actually uses this functionality but I mentioned blink-likes in my notes.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 14 Jun 2011, 12:06
by friarsol
Hellfish wrote:EDIT: Welp, now I remembered why I put TriggeringObjects in Card instead of anywhere else: So that they'd persist long enough for delayed triggers to make use of them. I don't know if there are any cards that actually uses this functionality but I mentioned blink-likes in my notes.
Alright I'll test those when I get a chance this week since I need it for the work I'm doing and make any appropriate changes. I should be able to figure out a way to keep things working the way I have it now, without losing any of the original functionality.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 15 Jun 2011, 00:36
by jeffwadsworth
Chris, try placing a trigger on the token to exile itself when Stangg leaves. That should work like a charm.



Chris H. wrote:Over the last couple of months I have tried my best to convert Stangg. I now have all three triggers working, but only two of the three abilities called by the triggers are working.

When Stangg leaves the battlefield, the token remains on the battlefield and is not being exiled.

Stangg card | Open
Name:Stangg
ManaCost:4 R G
Types:Legendary Creature Human Warrior
Text:no text
PT:3/4
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigToken | TriggerDescription$ When CARDNAME enters the battlefield, put a legendary 3/4 red and green Human Warrior creature token named Stangg Twin onto the battlefield. When CARDNAME leaves the battlefield, exile that token. When that token leaves the battlefield, sacrifice CARDNAME.
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Any | ValidCard$ Card.Self | Execute$ TrigExile | Secondary$ True | TriggerDescription$ When CARDNAME enters the battlefield, put a legendary 3/4 red and green Human Warrior creature token named Stangg Twin onto the battlefield. When CARDNAME leaves the battlefield, exile that token. When that token leaves the battlefield, sacrifice CARDNAME.
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Any | ValidCard$ Creature.token+namedStangg Twin | Execute$ TrigSac | Secondary$ True | TriggerDescription$ When CARDNAME enters the battlefield, put a legendary 3/4 red and green Human Warrior creature token named Stangg Twin onto the battlefield. When CARDNAME leaves the battlefield, exile that token. When that token leaves the battlefield, sacrifice CARDNAME.
SVar:TrigToken:AB$Token | Cost$ 0 | TokenAmount$ 1 | TokenName$ Stangg Twin | TokenTypes$ Legendary,Creature,Human,Warrior | TokenOwner$ You | TokenColors$ Red,Green | TokenPower$ 3 | TokenToughness$ 4
SVar:TrigExile:AB$ChangeZone | Cost$ 0 | Origin$ Battlefield | Destination$ Exile | ChangeType$ Creature.token+namedStangg Twin | ChangeNum$ 1
SVar:TrigSac:AB$Sacrifice | Cost$ 0 | SacValid$ Card.Self
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/stangg.jpg
SetInfo:LEG|Rare|http://magiccards.info/scans/en/lg/300.jpg
End

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 15 Jun 2011, 00:50
by Chris H.
jeffwadsworth wrote:Chris, try placing a trigger on the token to exile itself when Stangg leaves. That should work like a charm.
`
Thank you for the suggestion.

I will try to find some time to go back and finish this conversion.

I suspect that there may still be a few hard coded cards that can be converted. But no too many. 8)