It is currently 12 Sep 2025, 13:36
   
Text Size

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

Postby slapshot5 » 19 May 2011, 20:40

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
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

Postby 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
User avatar
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

Postby jeffwadsworth » 27 May 2011, 20:02

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.
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

Postby 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.
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

Postby 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. :mrgreen:
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
User avatar
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

Postby 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?
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

Postby Sloth » 01 Jun 2011, 10:24

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
User avatar
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

Postby friarsol » 01 Jun 2011, 12:18

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?
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

Postby Sloth » 01 Jun 2011, 12:59

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).
User avatar
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

Postby Hellfish » 05 Jun 2011, 19:20

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.
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
User avatar
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

Postby 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?
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

Postby 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.
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
User avatar
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

Postby friarsol » 14 Jun 2011, 12:06

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.
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

Postby 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

Postby 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. 8)
User avatar
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

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 33 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 33 users online :: 0 registered, 0 hidden and 33 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 33 guests

Login Form