It is currently 15 Aug 2025, 03:08
   
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 Zirbert » 01 Feb 2011, 03:01

Hellfish wrote:Added another example to the wiki page as requested by Zirbert, what, four pages ago? :oops:
No sweat - I'm still here, and still appreciate it! Thanks!

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

Code: Select all
Card host = AllZoneUtil.getCardState(regtrig.getHostCard());
I don't remember why I added it, and now that I'm trying to figure out how to fix ORing, I was trying to figure out if you remembered what the deal was. I'll try to sift back through the changes to figure out what the change was otherwise.

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)

Postby 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.
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 » 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
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 » 18 Feb 2011, 14:42

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. :/
That's fine. I'll have to play around with it and see if I can get a better way to repro.
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 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:
Code: Select all
AllZone.TriggerHandler.removeRegisteredTrigger(t);
card.removeTrigger(t);
The text is gone, but the trigger still fires.

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)

Postby 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
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 slapshot5 » 13 Mar 2011, 19:07

Hellfish wrote:EDIT: Misread, you were using removeRegisteredTrigger.. :? Hmm..
Ideally, I would just call c.removeTrigger(t) and that would handle the unregistering part.

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)
parsedTrigger is not the same as addedTrigger. c.addTrigger() returns a different trigger object than what was added. IIRC.

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

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

Postby 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
Code: Select all
if(regtrig instanceof Trigger_TapsForMana)
{
     Ability_Mana abMana = (Ability_Mana)runParams.get("Ability_Mana");
     //Set undoability here
}
OR set the undoability in the performTest method, which I don't really like.

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
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 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
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 12 guests

Main Menu

User Menu

Our Partners


Who is online

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

Login Form