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)
by Zirbert » 01 Feb 2011, 03:01
No sweat - I'm still here, and still appreciate it! Thanks!Hellfish wrote:Added another example to the wiki page as requested by Zirbert, what, four pages ago?
-Zirbert
Re: Trigger discussion (was WheneverKeyword reference)
by friarsol » 04 Feb 2011, 18:46
Hellfish,
It looks like when I sacrifice the newly created Kalastria Highborn to my Claws of Gix it doesn't trigger from itself dying. But Jeff said he tested with Combat Damage and it goes off. Seems like a weird hole that might have been overlooked?
It looks like when I sacrifice the newly created Kalastria Highborn to my Claws of Gix it doesn't trigger from itself dying. But Jeff said he tested with Combat Damage and it goes off. Seems like a weird hole that might have been overlooked?
- 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)
by Hellfish » 04 Feb 2011, 18:54
I'm pretty sure you'll have to use two triggers like I posted in the carddev thread. That's because if it's the Highborn itself that gets sent to the graveyard, it'll already be in the graveyard by the time the trigger conditions are evaluated, causing the TriggerZones restriction to fail.It's a bit odd about the combat damage bit working,though. I'll run some tests.
EDIT: Um, I don't know if he commited the same version of the card he tested, but for me it does not trigger when it goes to the graveyard from combat damage. I commited a fix,though.
EDIT: Um, I don't know if he commited the same version of the card he tested, but for me it does not trigger when it goes to the graveyard from combat damage. I commited a fix,though.
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: Trigger discussion (was WheneverKeyword reference)
by friarsol » 09 Feb 2011, 05:24
So it looks like the current issue with Oblivion Ring etc has to do with this line which I think I added at some point.
Edit: I just checked in a change for this, feel free to test for any side effects that I haven't thought of.
- Code: Select all
Card host = AllZoneUtil.getCardState(regtrig.getHostCard());
Edit: I just checked in a change for this, feel free to test for any side effects that I haven't thought of.
- 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)
by friarsol » 18 Feb 2011, 05:03
Hellfish, maybe you can debug this when you get some time:
Playing any Allies deck. AI Control Magic's one of my Allies, but it still triggers every time I play a new Ally. The AI happened to grab an Umara Raptor if you need a specific card to test.
Edit: Interestingly, in the next game the Raptor was stolen before I had other Allies in play. When I cast two new allies it didn't trigger. Not sure why the inconsistency.
Playing any Allies deck. AI Control Magic's one of my Allies, but it still triggers every time I play a new Ally. The AI happened to grab an Umara Raptor if you need a specific card to test.
Edit: Interestingly, in the next game the Raptor was stolen before I had other Allies in play. When I cast two new allies it didn't trigger. Not sure why the inconsistency.
- 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)
by Hellfish » 18 Feb 2011, 12:57
That is odd, I can't reproduce it at all. I tried with a variety of combinations of allies (several or solitary) and whatever ally was Control Magic -d does not trigger on me playing another ally. Sorry, but I officially have no clue. :/
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: Trigger discussion (was WheneverKeyword reference)
by friarsol » 18 Feb 2011, 14:42
That's fine. I'll have to play around with it and see if I can get a better way to repro.Hellfish wrote:That is odd, I can't reproduce it at all. I tried with a variety of combinations of allies (several or solitary) and whatever ally was Control Magic -d does not trigger on me playing another ally. Sorry, but I officially have no clue. :/
- 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)
by slapshot5 » 13 Mar 2011, 18:58
How does one successfully remove a trigger from a card and remove it from happening?
Think SP$Pump granting a trigger. What does the end of turn code look like? I'm using:
Check out Raging Ravine attacking on consecutive turns with its use of AF_Animate for an example. On the second of the 2 turns, the trigger fires twice even though the text is on the card only once.
-slapshot5
Think SP$Pump granting a trigger. What does the end of turn code look like? I'm using:
- Code: Select all
AllZone.TriggerHandler.removeRegisteredTrigger(t);
card.removeTrigger(t);
Check out Raging Ravine attacking on consecutive turns with its use of AF_Animate for an example. On the second of the 2 turns, the trigger fires twice even though the text is on the card only once.
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Trigger discussion (was WheneverKeyword reference)
by Hellfish » 13 Mar 2011, 19:00
EDIT: Misread, you were using removeRegisteredTrigger..
Hmm..

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: Trigger discussion (was WheneverKeyword reference)
by slapshot5 » 13 Mar 2011, 19:07
Ideally, I would just call c.removeTrigger(t) and that would handle the unregistering part.Hellfish wrote:EDIT: Misread, you were using removeRegisteredTrigger..Hmm..
When I was writing AF_Animate, I ran into some problem, that I don't remember all the specifics of, but:
- Code: Select all
Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, c);
Trigger addedTrigger = c.addTrigger(parsedTrigger)
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Trigger discussion (was WheneverKeyword reference)
by Hellfish » 13 Mar 2011, 19:13
Yeah you're right, the trigger objects are copied at various points to fix an issue I had when first implementing them, so the objects themselves won't match. I will commit a fix.
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: Trigger discussion (was WheneverKeyword reference)
by Hellfish » 13 Mar 2011, 19:26
Alright, should be good as of r7542. You were correct, so you don't have to change anything.
Triggers now simply carry an integer ID that is copied same as everything else when the trigger is copied.

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: Trigger discussion (was WheneverKeyword reference)
by slapshot5 » 17 Mar 2011, 04:26
I'm in the process of doing a TapsForMana trigger. I've got it all working, but the last piece I think is to make anything that trips the TapsForMana trigger undoable = false.
Any idea where one would do this? I'm looking at TriggerHandler. Where do I have access to the triggering Ability_Mana after knowing a trigger fired to do setUndoable(false);?
-slapshot5
Any idea where one would do this? I'm looking at TriggerHandler. Where do I have access to the triggering Ability_Mana after knowing a trigger fired to do setUndoable(false);?
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Trigger discussion (was WheneverKeyword reference)
by Hellfish » 17 Mar 2011, 09:51
That all depends on your implementation of the trigger. Where would the runTrigger call be from? If you have access to the Ability_Mana object there you could just pass it in via the runParams map. Of course, afterwards you'd have to either catch TapsForMana-Triggers in TriggerHandler.runTrigger along the lines of
OR I add a virtual method additionalOperations(Hashmap<String, Object> runParams) to the Trigger class that subclasses can override if they, like in this case, need to do something extra. The method would be called after it is confirmed that the trigger will actually go off, but before the wrapperability is played.
I like option 3, myself. I have no idea if that could actually be useful anywhere else though.
- Code: Select all
if(regtrig instanceof Trigger_TapsForMana)
{
Ability_Mana abMana = (Ability_Mana)runParams.get("Ability_Mana");
//Set undoability here
}
OR I add a virtual method additionalOperations(Hashmap<String, Object> runParams) to the Trigger class that subclasses can override if they, like in this case, need to do something extra. The method would be called after it is confirmed that the trigger will actually go off, but before the wrapperability is played.
I like option 3, myself. I have no idea if that could actually be useful anywhere else though.
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: Trigger discussion (was WheneverKeyword reference)
by slapshot5 » 17 Mar 2011, 13:50
The trigger is called from Ability_Mana.produceMana(String) for the Human and ComputerUtil.payManaCost(SpellAbility) for the computer.
a) I'll probably do it this way; it seems easiest. (There is no Ability_Mana from ComputerUtil, but the computer probably doesn't care about undoable anyway, huh?)
b) This was my first thought, but I really didn't like it either
c) I haven't seen anything else in my foray to triggers that would necessitate this. If we need it, fine, I'd use it, but I think it's like using a cannon when a BB gun would do (at this point anyway). Unless of course, option (a) doesn't work...
Thanks for the response. I'll give it a try.
-slapshot5
a) I'll probably do it this way; it seems easiest. (There is no Ability_Mana from ComputerUtil, but the computer probably doesn't care about undoable anyway, huh?)
b) This was my first thought, but I really didn't like it either
c) I haven't seen anything else in my foray to triggers that would necessitate this. If we need it, fine, I'd use it, but I think it's like using a cannon when a BB gun would do (at this point anyway). Unless of course, option (a) doesn't work...
Thanks for the response. I'll give it a try.
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Who is online
Users browsing this forum: No registered users and 22 guests