It is currently 11 Sep 2025, 20:46
   
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 Hellfish » 06 Mar 2011, 09:08

Sweet, just what I was hoping for :)
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 slapshot5 » 06 Mar 2011, 15:04

I'm trying to do Kodama of the Center Tree with triggers like this:
Code: Select all
Name:Kodama of the Center Tree
ManaCost:4 G
Types:Legendary Creature Spirit
Text:no text
PT:*/*
K:stSetPT:Count$Valid Spirit.YouCtrl:Count$Valid Spirit.YouCtrl:CARDNAME's power and toughness are each equal to the number of Spirits you control.
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | Optional$ True | ValidCard$ Card.Self | Execute$ TrigChange | TriggerDescription$ CARDNAME has soulshift X, where X is the number of Spirits you control. (When this is put into a graveyard from the battlefield, you may return target Spirit card with converted mana cost X or less from your graveyard to your hand.)
SVar:TrigChange:AB$ChangeZone | Cost$ 0 | Origin$ Graveyard | Destination$ Hand | ValidTgts$ Spirit.YouCtrl+cmcLEX
SVar:X:Count$Valid Spirit.YouCtrl
SVar:RemAIDeck:True
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/kodama_of_the_center_tree.jpg
End
The trigger starts to work, because it prompts me for a target, but the trigger doesn't go on the stack, and thus, never resolves.

I have 3 Spirits in play, then sacrifice Kodama (Crack the Earth), and target a Spirit with CMC 2 in my graveyard (Angelic Curator).

Any idea what's wrong?

-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 » 06 Mar 2011, 15:42

Hmm, I may have to debugger-delve into this one. I'll get back to you after dinner!
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 Hellfish » 06 Mar 2011, 16:30

Alright, I think there was a slight logic error in MagicStack.addAndUnfreeze() that prevented the stack from unfreezing after a triggered ability was put on it. If you continue the turn, it should pop up eventually.

I'll commit a fix after a quick quest session to ensure I don't break anything else here, since MagicStack is pretty unfamiliar territory to me.

EDIT:Commited.
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 slapshot5 » 06 Mar 2011, 22:41

I've got another trigger not resolving problem:

I converted Sword of Light and Shadow like this:
Code: Select all
Name:Sword of Light and Shadow
ManaCost:3
Types:Artifact Equipment
Text:Equipped creature gets +2/+2 and has protection from white and from black.
K:eqPump 2:+2/+2/Protection from white & Protection from black
#
#Testing ability without trigger
A:AB$GainLife | Cost$ 1 | Defined$ You | LifeAmount$ 3 | SubAbility$ SVar=DBReturn | SpellDescription$ Gain 3 life and return creature.
#
T:Mode$ DamageDone | ValidSource$ Creature.AttachedBy | ValidTarget$ Player | CombatDamage$ True | Execute$ TrigGainLife | TriggerZones$ Battlefield | TriggerDescription$ Whenever equipped creature deals combat damage to a player, you gain 3 life and you may return up to one target creature card from your graveyard to your hand.
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 3 | SubAbility$ SVar=DBReturn
SVar:DBReturn:DB$ChangeZone | Origin$ Graveyard | Destination$ Hand | ValidTgts$ Creature | TargetMin$ 0 | TargetMax$ 1 | TgtPrompt$ Select target creature in your graveyard
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/sword_of_light_and_shadow.jpg
SetInfo:DST|Rare|http://magiccards.info/scans/en/ds/149.jpg
End
The trigger goes on the stack, but no life gain happens, and I am not prompted to target a creature in my grave.

If I put this as an ability instead of a trigger (as seen in test code above), the life gain happens as expected and I am prompted to target a creature and the creature was return.

Grave for both tests contained:
Merfolk of the Pearl Trident
Zuran Orb

-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 slapshot5 » 06 Mar 2011, 23:26

Well, the Sword of Light and Shadow issue is something to do with ChangeZone or my use of it. If I take the DBReturn out, I gain life as expected when the trigger resolves.

-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 friarsol » 07 Mar 2011, 00:29

slapshot5 wrote:Well, the Sword of Light and Shadow issue is something to do with ChangeZone or my use of it. If I take the DBReturn out, I gain life as expected when the trigger resolves.

-slapshot5
I don't think it has anything to do with the how you are using ChangeZone. What's more likely is the target input is getting cleared out by the CombatDamage input. And so you just never get a chance to target.
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 slapshot5 » 15 Mar 2011, 13:56

I'm trying to make the Hound Pet use triggers. Here's what I'm doing:

Code: Select all
//petCard.addIntrinsicKeyword("Whenever this creature attacks alone, it gets +2/+0 until end of turn.");
           
final Trigger myTrigger = TriggerHandler.parseTrigger("Mode$ Attacks | ValidCard$ Card.Self | Alone$ True | TriggerDescription$ Whenever CARDNAME attacks alone, it gets +2/+0 until end of turn.", petCard);

AbilityFactory af = new AbilityFactory();

myTrigger.setOverridingAbility(af.getAbility("AB$Pump | Cost$ 0 | Defined$ Self | NumAtt$ 2", petCard));

petCard.addTrigger(myTrigger);

AllZone.TriggerHandler.registerTrigger(myTrigger);
replacing the commented out like with adding a trigger in code. The trigger description appears on the card, but the trigger doesn't fire.

What am I not doing correctly?

-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 Chris H. » 15 Mar 2011, 14:33

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

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 15 Mar 2011, 14:50

Slapshot5: The Attacks-trigger didn't get all the data it needed, must've gotten lost in a move somewhere. It works now. :)
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 slapshot5 » 15 Mar 2011, 15:24

Hellfish wrote:Slapshot5: The Attacks-trigger didn't get all the data it needed, must've gotten lost in a move somewhere. It works now. :)
I was going to say "Hey, it still doesn't work", but then I thought maybe if I updated my source tree, there was a better chance it would... *sigh*

Works like a charm. Thanks!

-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 friarsol » 18 May 2011, 03:58

Hellfish,
Is there a way to setup a Delayed Trigger right now off a SubAbility? I want to turn Mana Drain into "AF_Counter$. Create Delayed Trigger to add X mana to my mana pool."

I don't see any clear examples of this happening. Might have to tweak Effect to have Duration of "TriggerOnce" to allow this type of thing.
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 » 18 May 2011, 05:34

Not currently, though I can take a look at that during lunch/tonight.Delayed triggers are removed after triggering once anyway, since it's kinda in their nature, so AF_Effect probably won't be needed.
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 Hellfish » 18 May 2011, 19:11

I'm pondering how best to handle the AI of an eventual AF_Trigger. At first I thought it should be determined by the ability that triggers, but that isn't created until it's actually showtime for it.Not sure how else to do things.Maybe only allow the AF as a subability? Would that rule out any cards that could use it otherwise?
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 Hellfish » 19 May 2011, 19:26

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

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 36 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 36 users online :: 0 registered, 0 hidden and 36 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 36 guests

Login Form