It is currently 12 Sep 2025, 06:29
   
Text Size

Issue 113 Converting Hardcoded Cards to AFs/Trigger

Post MTG Forge Related Programming Questions Here

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

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 04 Mar 2011, 09:32

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.
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: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 04 Mar 2011, 12:58

Committed! :D
Now for writing documentation D:
EDIT: Check the triggers wiki page for documentation.
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: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 04 Mar 2011, 14:16

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.
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: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby slapshot5 » 04 Mar 2011, 19:52

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

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 04 Mar 2011, 20:16

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.
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: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby slapshot5 » 04 Mar 2011, 22:03

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

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 04 Mar 2011, 22:07

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.
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: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby slapshot5 » 04 Mar 2011, 22:19

True. But just for consistency. If these were implemented as two different ones, would Essence Sliver be simplified to just: Count$TriggeredCardController ?
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby friarsol » 05 Mar 2011, 03:33

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 05 Mar 2011, 08:31

I wasn't aware AttackerUnblocked's runTrigger call was taken out. o_O Oh well, it does look correct. Thanks!
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: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby friarsol » 05 Mar 2011, 14:12

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby slapshot5 » 05 Mar 2011, 22:48

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

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby Hellfish » 05 Mar 2011, 22:52

Sounds good. I may tweak Optional a bit to act as Defined$ for players.Are there more cards like Fecundity?
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: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby slapshot5 » 05 Mar 2011, 23:30

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

Re: Issue 113 Converting Hardcoded Cards to AFs/Trigger

Postby slapshot5 » 06 Mar 2011, 02:34

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
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 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 12 guests

Login Form