It is currently 14 Aug 2025, 22:03
   
Text Size

Trigger discussion (was WheneverKeyword reference)

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: Trigger discussion (was WheneverKeyword reference)

Postby Hellfish » 12 Jan 2011, 20:26

Well, I'm pretty sure I've taken care of the trigger ordering(It's at least in APNAP order now :) ), and just maybe at least some of the "intervening if" problem as well though that will take some testing. What I'm trying is; I wrap the SpellAbility I get from the AbilityFactory in another Ability object, which in it's resolve calls the AF's spellability's resolve but not before doing the same restrictionCheck() that is done when the trigger first goes off (which will, and currently does, handle all checks from intervening ifs) I then play this wrapper instead.
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: Trigger discussion (was WheneverKeyword reference)

Postby friarsol » 15 Jan 2011, 14:33

Hellfish, can you merge your Trigger docs into the Wiki attached in a few places like how everything else is?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby Sloth » 15 Jan 2011, 15:01

I just tested the card Abyssal Horror, you converted and it:

a) triggers when any card enters the battlefield and
b) while Abyssal Horror is in your hand.

Code: Select all
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | Execute$ TrigDiscard | TriggerDescription$ When CARDNAME enters the battlefield, target player discards two cards.
EDIT: I added "ValidCard$ Card.Self | " and the issue is gone, but now the ability triggered 4 times, when Abyssal Horror etB'ed!
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby jeffwadsworth » 15 Jan 2011, 17:24

I was testing Desolation Angel implementation with triggers. When it triggered, 4 Abyssal Horror discard 2 messages stacked up. There were no cards of this type in either deck. Please disregard the cost of the cards...test.
Code: Select all
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigDestroyLand | TrigDescription$ Test
SVar:TrigDestroyLand:AB$DestroyAll | Cost$ 3 B B | ValidCards$ Land.YouCtrl | SpellDescription$ Destroy all lands you control.
Attachments
Issue.png
jeffwadsworth
Super Tester Elite
 
Posts: 1172
Joined: 20 Oct 2010, 04:47
Location: USA
Has thanked: 287 times
Been thanked: 70 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby Hellfish » 16 Jan 2011, 01:55

Once I´ve sobered up I will
A) I've already added the trigger docs I had to the wiki
B) I will test Abyssal Horror more closely to see what is up with that.
C) I will look into the desolation angel issue.

Thanks for reporting things! :)
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: Trigger discussion (was WheneverKeyword reference)

Postby friarsol » 16 Jan 2011, 02:25

Hellfish wrote:Once I´ve sobered up I will
A) I've already added the trigger docs I had to the wiki
B) I will test Abyssal Horror more closely to see what is up with that.
C) I will look into the desolation angel issue.

Thanks for reporting things! :)
I don't think the Desolation Angel is an issue. Desolation Angel needs to be kicked while it's being cast. Then during the Trigger it should either kill your lands, or if it was kicked kill all lands. I'm not sure if this conditional can be handled right now.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby jeffwadsworth » 16 Jan 2011, 02:42

Let me be a little clearer. I was only testing one part of Desolation Angel. I am aware that you can stack spells to account for Kicker; for example Urza's Rage. I noticed that you can not currently do that with Triggers. My point in the previous post was to note a strange error with the Abyssal Horror.

On a side note, the card Sunblast Angel does not work correctly. Sometimes it will destroy the tapped creatures and at others, nothing happens.
Last edited by jeffwadsworth on 16 Jan 2011, 03:09, edited 2 times in total.
jeffwadsworth
Super Tester Elite
 
Posts: 1172
Joined: 20 Oct 2010, 04:47
Location: USA
Has thanked: 287 times
Been thanked: 70 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby friarsol » 16 Jan 2011, 02:56

Oh alright.

Just so you know comparing the Angel to Rage isn't exactly apples to oranges though, since for non-permanent spells you can have the Kicker cost included in the cost to allow for a "kicked" spell. But for permanent spells there isn't a way to change the casting cost to account for being kicked and using a different Trigger.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby Hellfish » 16 Jan 2011, 19:44

jeffwadsworth wrote:I was testing Desolation Angel implementation with triggers. When it triggered, 4 Abyssal Horror discard 2 messages stacked up. There were no cards of this type in either deck. Please disregard the cost of the cards...test.
Code: Select all
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigDestroyLand | TrigDescription$ Test
SVar:TrigDestroyLand:AB$DestroyAll | Cost$ 3 B B | ValidCards$ Land.YouCtrl | SpellDescription$ Destroy all lands you control.
Withe your added ValidCard restriction, the card worked fine here. May have been something related that someone else fixed elsewhere. I'll add your fix though, thanks!
friarsol wrote:Oh alright.

Just so you know comparing the Angel to Rage isn't exactly apples to oranges though, since for non-permanent spells you can have the Kicker cost included in the cost to allow for a "kicked" spell. But for permanent spells there isn't a way to change the casting cost to account for being kicked and using a different Trigger.
If we add some way to specify kicker-costs(Single costs at least) in text-only, the triggers can be used as-is for that sort of thing. i.e.
Code: Select all
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self+kicked etc...
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: Trigger discussion (was WheneverKeyword reference)

Postby friarsol » 16 Jan 2011, 20:10

Hellfish wrote:If we add some way to specify kicker-costs(Single costs at least) in text-only, the triggers can be used as-is for that sort of thing. i.e.
Code: Select all
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self+kicked etc...
Yep kicked and nonkicked would probably be a good way to handle these types of things.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby Zirbert » 19 Jan 2011, 03:20

Any chance we could get a phase-trigger example added to the wiki (http://www.slightlymagic.net/wiki/User:Hellfish/Trigger), to go with the Contagion Clasp example? That one's great - I especially like the annotation / code commenting - but I can't quite grok the syntax if I'm trying to code a card that says "At the beginning of your upkeep, do X".

Or, if somebody could point me toward some cards in the 01-14 beta that use the new trigger syntax, I'll try to do my own homework from there.

I'm still hoping to eventually contribute a card or two to this project, but I am - and will doubtlessly remain - an utter neophyte at coding (and that's being generous). I've got to read other text-implemented cards and cobble things together from there.

-Zirbert
http://zirbert.blogspot.com
Zirbert
 
Posts: 512
Joined: 13 Oct 2010, 16:04
Has thanked: 104 times
Been thanked: 19 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby Sloth » 19 Jan 2011, 06:18

Zirbert wrote:Or, if somebody could point me toward some cards in the 01-14 beta that use the new trigger syntax, I'll try to do my own homework from there.
You can take a peek at what's been submitted to the SVN here: http://code.google.com/p/cardforge/source/list. At the moment a lot of cards with the trigger mechanic are added or converted.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby Hellfish » 19 Jan 2011, 07:41

I'll write up another example this afternoon. Also, there are no "official" cards using the trigger-system included in the 1-14 beta because it needed alot of additional polish before public release, or we'd have to do alot more frequent betas for a time afterwards to address fixes that can be quite serious. (For a time, trigger system cards only worked correctly if there were no more than one in the game! o_O)
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: Trigger discussion (was WheneverKeyword reference)

Postby Zirbert » 19 Jan 2011, 22:44

Thanks for the tips on finding trigger examples! Confession time - until last night, I had no idea there were docs on coding in the wiki, and didn't know about the Committed Changes page until Sloth pointed me toward it. I'm getting a lot better idea how to write up a card or three.

I *think* this will work. Those who already know what you're doing, please feel free to correct my errors. And don't worry about being gentle, I want to learn. My first (finished) card attempt:

Code: Select all
Name: Merrow Commerce
ManaCost:1 U
Types: Tribal Enchantment Merfolk
Text: At the beginning of your end step, untap all Merfolk you control.
T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | Execute$ UntapMerfolk | TriggerDescription$ At the beginning of your end step, untap all Merfolk you control.
SVar:UntapMerfolk:A:SP$UntapAll|Cost$0|ValidCards$Merfolk.YouCtrl|SpellDescription$Untap all Merfolk you control.
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
#SVar:Picture:http://www.wizards.com/global/images/magic/general/merrow_commerce.jpg
SVar:Picture:http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=139663&type=card
SetInfo:LRW|Uncommon|http://magiccards.info/scans/en/lw/72.jpg
I'm running the 1-14 beta, and it really doesn't like this card being added to /res/cardsfolder - it makes my Forge throw up on attempted boot with this error:

Code: Select all
null


Version:
Forge -- official beta: $Date: 2011-01-06 11:34:48 -0500 (Thu, 06 Jan 2011) $, SVN revision: $Revision: 4891 $

OS: Linux Version: 2.6.31-9-rt Architecture: amd64

Java Version: 1.6.0_18 Vendor: Sun Microsystems Inc.

Detailed error trace:
java.lang.NullPointerException
   at forge.ReadCard.loadCard(ReadCard.java:154)
   at forge.ReadCard.run(ReadCard.java:118)
   at forge.CardFactory.readCards(CardFactory.java:92)
   at forge.CardFactory.<init>(CardFactory.java:66)
   at forge.AllZone.<clinit>(AllZone.java:29)
   at forge.Gui_NewGame$2.run(Gui_NewGame.java:185)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:602)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
I'm going to assume (hope) that this is because I'm running an "old" version that can't handle the new trigger coding. I'm not quite ready to try running SVN just yet. Or it could be because I've coded something completely nonsensical and heinous. Feedback is welcome...

-Zirbert
Zirbert
 
Posts: 512
Joined: 13 Oct 2010, 16:04
Has thanked: 104 times
Been thanked: 19 times

Re: Trigger discussion (was WheneverKeyword reference)

Postby friarsol » 19 Jan 2011, 23:20

Zirbert wrote:
Code: Select all
Name: Merrow Commerce
ManaCost:1 U
Types: Tribal Enchantment Merfolk
Text: At the beginning of your end step, untap all Merfolk you control.
T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | Execute$ UntapMerfolk | TriggerDescription$ At the beginning of your end step, untap all Merfolk you control.
SVar:UntapMerfolk:A:AB$UntapAll|Cost$0|ValidCards$Merfolk.YouCtrl|SpellDescription$Untap all Merfolk you control.
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
#SVar:Picture:http://www.wizards.com/global/images/magic/general/merrow_commerce.jpg
SVar:Picture:http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=139663&type=card
SetInfo:LRW|Uncommon|http://magiccards.info/scans/en/lw/72.jpg
This isn't going to work in the beta for a few reasons.

1. Card Files need to have "End" as the last line in the file.
2. Phase triggers weren't setup for End of Turn yet
3. It needs to be AB$ (for Ability) not A:SP$ (for Spell) (And the A: isn't used)

Also don't put spaces after the Colon I'll see if I can get this working as expected.

Edit: I might have lied about it not being setup in the beta.

Try this and see if it works:

Code: Select all
Name:Merrow Commerce
ManaCost:1 U
Types:Tribal Enchantment Merfolk
Text:no text
T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | Execute$ TrigUntapMerfolk | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your end step, untap all Merfolk you control.
SVar:TrigUntapMerfolk:AB$UntapAll|Cost$0|ValidCards$Merfolk.YouCtrl|SpellDescription$Untap all Merfolk you control.
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
#SVar:Picture:http://www.wizards.com/global/images/magic/general/merrow_commerce.jpg
SVar:Picture:http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=139663&type=card
SetInfo:LRW|Uncommon|http://magiccards.info/scans/en/lw/72.jpg
End
[/code]
Last edited by friarsol on 19 Jan 2011, 23:25, edited 2 times in total.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 41 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 41 users online :: 0 registered, 0 hidden and 41 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 41 guests

Login Form