Issue 113 Converting Hardcoded Cards to AFs/Trigger
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by slapshot5 » 19 May 2011, 20:40
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.Hellfish wrote:So with a few mods to AF_CounterMagic and a very barebones AF_DelayedTrigger I was able to get this seemingly working:Thoughts?
- 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
The AF_DelayedTrigger I have now only provides for subabilities and just returns false for any AI checks.
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by Hellfish » 19 May 2011, 20:57
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.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
-
Hellfish - Programmer
- Posts: 1297
- Joined: 07 Jun 2009, 10:41
- Location: South of the Pumphouse
- Has thanked: 110 times
- Been thanked: 169 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by jeffwadsworth » 27 May 2011, 20:02
It works perfectly fine here. Thanks.Hellfish wrote:So with a few mods to AF_CounterMagic and a very barebones AF_DelayedTrigger I was able to get this seemingly working:Thoughts?
- 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
The AF_DelayedTrigger I have now only provides for subabilities and just returns false for any AI checks.
- jeffwadsworth
- Super Tester Elite
- Posts: 1172
- Joined: 20 Oct 2010, 04:47
- Location: USA
- Has thanked: 287 times
- Been thanked: 70 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by friarsol » 31 May 2011, 03:20
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.
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.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by Hellfish » 31 May 2011, 06:04
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.
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.

So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
-
Hellfish - Programmer
- Posts: 1297
- Joined: 07 Jun 2009, 10:41
- Location: South of the Pumphouse
- Has thanked: 110 times
- Been thanked: 169 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by friarsol » 31 May 2011, 12:16
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?
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?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by Sloth » 01 Jun 2011, 10:24
Actually they have to be checked at other times too: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?
- Card draw (Akki Underling)
- Add Mana to Manapool (Omnath, Locus of Mana)
- Something becomes tapped (Maraxus of Keld)
- Counters get removed
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by friarsol » 01 Jun 2011, 12:18
Not all Card Draw though right? Just the State based effect at the beginning of your turn?Sloth wrote:Actually they have to be checked at other times too: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?
- Card draw (Akki Underling)
- Add Mana to Manapool (Omnath, Locus of Mana)
- Something becomes tapped (Maraxus of Keld)
- Counters get removed
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?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by Sloth » 01 Jun 2011, 12:59
This should cover everything (ignoring some obscure corner cases such as Circling Vultures).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?
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by Hellfish » 05 Jun 2011, 19:20
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.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?
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
-
Hellfish - Programmer
- Posts: 1297
- Joined: 07 Jun 2009, 10:41
- Location: South of the Pumphouse
- Has thanked: 110 times
- Been thanked: 169 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by friarsol » 12 Jun 2011, 20:39
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?
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?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by Hellfish » 14 Jun 2011, 10:23
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.
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.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
-
Hellfish - Programmer
- Posts: 1297
- Joined: 07 Jun 2009, 10:41
- Location: South of the Pumphouse
- Has thanked: 110 times
- Been thanked: 169 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by friarsol » 14 Jun 2011, 12:06
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.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.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by jeffwadsworth » 15 Jun 2011, 00:36
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
- jeffwadsworth
- Super Tester Elite
- Posts: 1172
- Joined: 20 Oct 2010, 04:47
- Location: USA
- Has thanked: 287 times
- Been thanked: 70 times
Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger
by Chris H. » 15 Jun 2011, 00:50
`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.

-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Who is online
Users browsing this forum: No registered users and 97 guests