Page 7 of 8

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 01 Feb 2011, 03:01
by Zirbert
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

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 04 Feb 2011, 18:46
by friarsol
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?

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 04 Feb 2011, 18:54
by Hellfish
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.

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 09 Feb 2011, 05:24
by friarsol
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.

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 18 Feb 2011, 05:03
by friarsol
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.

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 18 Feb 2011, 12:57
by Hellfish
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. :/

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 18 Feb 2011, 14:42
by friarsol
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.

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 13 Mar 2011, 18:58
by slapshot5
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

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 13 Mar 2011, 19:00
by Hellfish
EDIT: Misread, you were using removeRegisteredTrigger.. :? Hmm..

Re: Trigger discussion (was WheneverKeyword reference)

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

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 13 Mar 2011, 19:13
by Hellfish
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.

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 13 Mar 2011, 19:26
by Hellfish
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.

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 17 Mar 2011, 04:26
by slapshot5
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

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 17 Mar 2011, 09:51
by Hellfish
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.

Re: Trigger discussion (was WheneverKeyword reference)

PostPosted: 17 Mar 2011, 13:50
by slapshot5
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