Page 4 of 7

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 09:32
by Hellfish
I'm pondering a more generalized system for getting at the triggering objects.
The reason DamageDone doesn't work with Triggered right now is because ATM, the trigger classes can only return one thing as Triggered. And does DamageDone return the target or the source of the damage?
EDIT:Not so much pondering as attempting to implement now. Once I wrangle this new code into submission you will be able to access triggermode specific parameters. For example "TriggeredSource" can be used with a DamageDone trigger to get the card that is the source of the damage (And vice versa with the accompanying "TriggeredTarget".Note that Target and Source are specific to DamageDone). You can get the controller or owner of the cards simply by appending Controller or Owner to the parameter name.

EDIT2: One drawback I'm seeing now is that some cards will require two different abilities to trigger where we got away with one before. Worth it? I think so.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 12:58
by Hellfish
Committed! :D
Now for writing documentation D:
EDIT: Check the triggers wiki page for documentation.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 14:16
by Hellfish
To avoid having anyone do unnecessary double work, I can say that I am in the process of obsoleting the "Whenever CARDNAME blocks/becomes blocked, destroy blocked/blocking creature at end of combat" keywords.

EDIT:Actually, it appears Abomination and friends are affected by not using DefinedCards in AF_Destroy's resolve. Therefore they are at odds with Parallax Dementia, like Dread on the previous page.It can wait.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 19:52
by slapshot5
I'm trying to convert Essense Sliver to triggers like so:
Code: Select all
Name:Essence Sliver
ManaCost:3 W
Types:Creature Sliver
Text:no text
PT:3/3
T:Mode$ DamageDone | ValidSource$ Sliver | Execute$ TrigGain | TriggerZones$ Battlefield | TriggerDescription$ Whenever a Sliver deals damage, its controller gains that much life.
SVar:TrigGain:AB$GainLife | Cost$ 0 | Defined$ TriggeredCardController | LifeAmount$ X
SVar:X:Count$TriggeredDamageAmount
SVar:PlayMain1:TRUE
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/essence_sliver.jpg
SetInfo:LGN|Rare|http://magiccards.info/scans/en/le/13.jpg
SetInfo:TSB|Special|http://magiccards.info/scans/en/tsts/8.jpg
End
But, It's giving NullPointerErrors when trying to put the trigger on the stack. It's failing with the "Defined$ TriggeredCardController"

Am I doing it wrong?

-slapshot5

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 20:16
by Hellfish
Yes, DamageDone does not provide a TriggeredCard. Only TriggeredSource and TriggeredTarget (And TriggeredDamageAmount but that doesn't apply here). For Essence Sliver it should be TriggeredSourceController.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 22:03
by slapshot5
Got it. Works much better.

I was thinking about this a little. Would it be better to split this into two different triggers?

DealsDamage - from source deals damage to something
DealtDamage - from target (or non-targeted) receiving damage

-slapshot5

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 22:07
by Hellfish
Better to call them DealsDamage and RecievesDamage, just to differentiate, in that case. The functionality's already there though, now that Triggered-Variables are in.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 04 Mar 2011, 22:19
by slapshot5
True. But just for consistency. If these were implemented as two different ones, would Essence Sliver be simplified to just: Count$TriggeredCardController ?

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 05 Mar 2011, 03:33
by friarsol
Hellfish, I just added AttackerUnblocked (back?) in. I think I did it right, but feel free to check it out to make sure it's not a terrible blunder. It did work for Swamp Mosquito (which is all that matters), so hopefully we won't need to do anything else for it.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 05 Mar 2011, 08:31
by Hellfish
I wasn't aware AttackerUnblocked's runTrigger call was taken out. o_O Oh well, it does look correct. Thanks!

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 05 Mar 2011, 14:12
by friarsol
Hellfish wrote:I wasn't aware AttackerUnblocked's runTrigger call was taken out. o_O Oh well, it does look correct. Thanks!
I'm not sure when it stopped working, but it wasn't around when I moved the Unblocked code out of the Damage step.

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 05 Mar 2011, 22:48
by slapshot5
slapshot5 wrote:I tried to convert Fecundity to triggers, but ran into a problem. When AI's creatures were put into the graveyard when I had Fecundity in play, I was prompted for the Optional$ use of Fecundity.

Here is my Fecundity with triggers:
Code: Select all
Name:Fecundity
ManaCost:2 G
Types:Enchantment
Text:no text
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Creature | TriggerZones$ Battlefield | Execute$ TrigDraw | Optional$ True | TriggerDescription$ Whenever a creature is put into a graveyard from the battlefield, that creature's controller may draw a card.
SVar:TrigDraw:AB$Draw | Cost$ 0 | Defined$ TriggeredController | NumCards$ 1
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/fecundity.jpg
SetInfo:8ED|Uncommon|http://magiccards.info/scans/en/8e/247.jpg
SetInfo:USG|Uncommon|http://magiccards.info/scans/en/us/251.jpg
End
I'm pretty certain the trigger and ability are right. Is this just a edge case interaction of Optional$ True and Defined$ TriggeredController?

Note: If I choose to use the Fecundity trigger, the AI - correctly - is the one to draw the card for his/her creatures.

-slapshot5
I ended up adding a TriggeredControllerDecides to the Optional$ parsing in TriggerHandler. r7136.

-slapshot5

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 05 Mar 2011, 22:52
by Hellfish
Sounds good. I may tweak Optional a bit to act as Defined$ for players.Are there more cards like Fecundity?

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 05 Mar 2011, 23:30
by slapshot5
Hellfish wrote:Sounds good. I may tweak Optional a bit to act as Defined$ for players.Are there more cards like Fecundity?
Maybe a couple, but my card knowledge of anything after Fallen Empires is pretty limited.

Possibly things like:
Pattern of Rebirth
Verdant Succession


-slapshot5

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

PostPosted: 06 Mar 2011, 02:34
by slapshot5
Hellfish - Nice job on this generalized system. It did exactly what I'd hoped. I just converted Seizan, Perverter of Truth to triggers like this:

Code: Select all
Name:Seizan, Perverter of Truth
ManaCost:3 B B
Types:Legendary Creature Demon Spirit
Text:no text
PT:6/5
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ Player | TriggerZones$ Battlefield | Execute$ TrigDrain | TriggerDescription$ At the beginning of each player's upkeep, that player loses 2 life and draws two cards.
SVar:TrigDrain:AB$LoseLife | Cost$ 0 | Defined$ TriggeredPlayer | LifeAmount$ 2 | SubAbility$ SVar=DBDraw
SVar:DBDraw:DB$Draw | Defined$ TriggeredPlayer | NumCards$ 2
SVar:Rarity:Rare
SVar:Picture:http://resources.wizards.com/magic/cards/chk/en-us/card78965.jpg
SetInfo:CHK|Rare|http://magiccards.info/scans/en/chk/143.jpg
End
Nice and streamlined.

-slapshot5