It is currently 31 Oct 2025, 19:28
   
Text Size

SpellAbility_Restriction

Post MTG Forge Related Programming Questions Here

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

SpellAbility_Restriction

Postby friarsol » 20 Oct 2010, 02:44

I just submitted the early code for SpellAbility_Restriction. The point of this code is to allow for altering of some default values of when an Ability can be activated.

At this time, only ActivatingZone is available through SA_Restriction. But this will allow us to use cards that have Channel, Reinforce (and lots of others).

ActivatingZone is only being checked for in the base AbilityFactory, and will set SA_Restriction appropriately. As our AbilityFactories grow, we will be able to support more and more corner cases without extra code blocks.

Here is one of the two Channel creatures that I submitted.

Code: Select all
Name:Ghost-Lit Raider
ManaCost:2 R
Types:Creature Spirit
Text:no text
A:AB$DealDamage|Cost$2 R T|Tgt$TgtC|NumDmg$2|SpellDescription$CARDNAME deals 2 damage to target creature.
A:AB$DealDamage|Cost$3 R Discard<1/CARDNAME>|Tgt$TgtC|NumDmg$4|ActivatingZone$Hand|SpellDescription$CARDNAME deals 4 damage to target creature.
PT:2/1
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/ghost_lit_raider.jpg
End
And one of the two Reinforce creatures

Code: Select all
Name:Mosquito Guard
ManaCost:W
Types:Creature Kithkin Soldier
Text:no text
K:First Strike
A:AB$PutCounter|Cost$1 W Discard<1/CARDNAME>|Tgt$TgtC|CounterType$P1P1|ActivatingZone$Hand|CounterNum$1|SpellDescription$Put a +1/+1 counter on target creature.
PT:1/1
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/mosquito_guard.jpg
End
Enjoy. SA_Restriction has a bunch of stuff planned out for it. If you have a preference I can do one sooner rather than later.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: SpellAbility_Restriction

Postby Sloth » 20 Oct 2010, 05:27

Very nice Sol!

I thought about Phase/Step restrictions this weekend, for cards like Alaborn Veteran, Angus Mackenzie or Augur il-Vec. I guess this would be the place to implement them. Sorcery speed abilities (like Amulet of Unmaking) can also have their restriction here.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: SpellAbility_Restriction

Postby friarsol » 21 Oct 2010, 03:35

Alright I've added a few more Restrictions today. All of these can be used through an AbilityFactory ability. It is possible to set the ability in a code block, although we still have lots to gain through these Abilities. See my example of Volrath's Dungeon if you are curious how the codeblock setting works.

"SorcerySpeed$True" - Can only be Activated when you can cast a sorcery.
"PlayerTurn$True" - Can only be Activated during your turn.
"AnyPlayer$True" - Can be Activated by Any player (this overwrites existing functionality and works better as well)
"ActivationLimit$X" - Can only be Activated X times per turn (Resets every Untap phase).

ActivationLimit will be able to replace AbilityLimits and canUseAbility in CardFactoryUtil, once Rob is done with AF_Pump.

I'll look into the Phase Restrictions next. The other restrictions I have as possibilities are Threshold Abilities, Metalcraft Abilities, and Abilities that are gained at certain levels for Levelers.

I think Retrace should work out of the box with ActivatingZone
Code: Select all
Flame Jab
A:SP$DealDamage|Cost$R|Tgt$TgtCP|NumDmg$1|SpellDescription$Flame Jabdeals 1 damage to target creature or player.
A:SP$DealDamage|Cost$R Discard<1/Land>|Tgt$TgtCP|NumDmg$1|ActivatingZone$Graveyard|SpellDescription$Flame Jab deals 1 damage to target creature or player.
Unearth and Flashback could work similarly, they would just need to add a flag, to properly link into the code that already exists for each Ability.

If you have an idea of something else that fits here just post about it and I'll take a look.

Edit: Fixing Flame Jab's sample code
Last edited by friarsol on 01 Nov 2010, 03:00, edited 1 time in total.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: SpellAbility_Restriction

Postby Rob Cashwalker » 21 Oct 2010, 04:05

Only activate/cast spell during a particular phase/step.

The Pump thing is almost done, at least for the spells and targeted pump abilities. I'm getting cross-eyed with all the differences the ability has had added on since I did them originally - targeting self or the equipping creature, etc.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: SpellAbility_Restriction

Postby friarsol » 21 Oct 2010, 17:25

I started looking at the phase stuff, but it's a bit messy right now. I may end up being sidetracked and trying to fix this all up before getting the Restriction to work. Although it's probably well worth the effort to get this rolling.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: SpellAbility_Restriction

Postby friarsol » 02 Nov 2010, 04:28

I've added the current SA_Restrictions into the Wiki for any interested.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: SpellAbility_Restriction

Postby Hellfish » 02 Nov 2010, 07:20

Reading through that list got me thinking that a Metalcraft$True restriction would be good. At least for Argent Sphinx,Kuldotha Phoenix,Mox Opal & Vedalken Certarch.
With an accompanying Metalcraft$False, Stoic Rebuttal (Two Ability_Factory(Once spCounter is replaced by a Ability_Factory, of course.Woo, got a new project :mrgreen: ) spells, one with True one with False and each with the appropriate cost)could also be an easy add. I was going to say that Galvanic Blast could also benefit from it, but that could theoretically change while Galvanic Blast is on the stack with damage amount already selected (By flashing a Darksteel Sentinel, for instance, or having an artifact Shatter ed..)
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: SpellAbility_Restriction

Postby friarsol » 02 Nov 2010, 14:24

Yep CardsYouControl is the next thing planned for this. Metalcraft is the same as any card that just cares if you have a certain number of permanents in play.

I'm undecided if having a shorthand for Metalcraft is really necessary.

So Vedalken Certarch ability would be something like this (once Tap is converted to an AF)
Code: Select all
A:SP$Tap|Cost$T|ValidTgts$Artifact,Creature,Land|TgtPrompt$Select target permanent|TypeYouControl$Artifact|NumYouControl$3|SpellDescription$Tap target permanent.
with shorthand it would be
Code: Select all
A:SP$Tap|Cost$T|ValidTgts$Artifact,Creature,Land|TgtPrompt$Select target permanent|Metalcraft$True|SpellDescription$Tap target permanent.
with code that would have Metalcraft set Type to Artifact and Num to 3 behind the scenes. It may be worth the cleaner look.


I can't tell if your two examples for Spells work quite right. Restriction's function is to tell the engine if you can legally play a spell or ability. Your examples change the card when it's being cast (Casting Cost lowering) or when it resolves (more damage).

If NumYouControl handles Comparisons, then Stoic Rebuttal might look like this:

Code: Select all
A:SP$Counter|Cost$1 U U|ValidTgts$Spell|TgtPrompt$Select target spell|TypeYouControl$Artifact|NumYouControl$LE2|SpellDescription$Counter target spell.
A:SP$Counter|Cost$U U|ValidTgts$Spell|TgtPrompt$Select target spell|TypeYouControl$Artifact|NumYouControl$GE3|SpellDescription$Counter target spell.
Which could work out nicely in some cases.

Theoretically, SA_Restriction can be expanded to handle all of the Traps.

Take Lethargy Trap for example (with assumed future AFs and Restrictions)
Code: Select all
Name:Lethargy Trap
ManaCost:3 U
Types:Instant Trap
Text:no text
A:SP$PumpAll|Cost$3 U|Type$Creature.Attacking|NumAtk$-3|SpellDescription$
Attacking creatures get -3/-0 until end of turn.
A:SP$PumpAll|Cost$U|Type$Creature.Attacking|AttackingCreatures$GE3|NumAtk$-3|SpellDescription$
Attacking creatures get -3/-0 until end of turn.
End
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: SpellAbility_Restriction

Postby Sloth » 02 Nov 2010, 16:14

For the general approach I would suggest using getValidCards like I used with isPresent for the stPump keyword:

Metalcraft:
Code: Select all
isPresent$Artifact.YouCtrl|Num$GE3
Lethargy Trap:
Code: Select all
isPresent$Creature.attacking|Num$GE3
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: SpellAbility_Restriction

Postby friarsol » 02 Nov 2010, 16:34

I had been planning on using getValidCards() but it looks like that may not have been clear.

I had partially forgotten about the .YouCtrl portion of that code, which does simplify this down to "IsPresent".

Actually, I can knock this out right now. Let's see what I have in 20 minutes.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: SpellAbility_Restriction

Postby friarsol » 05 Nov 2010, 04:27

Sloth, can we use stPump as a way for Levelers to change their P/T/Keywords? I'm pretty sure my samples won't work, but does something similar work?

Ex. Caravan Escort
Code: Select all
Name:Caravan Escort
ManaCost:W
Types:Creature Human Knight
Text:LEVEL 1-4 2/2 LEVEL 5+ 5/5 First Strike
PT:1/1
K:Level up:2
K:stPumpSelf:Creature:1/1:countersLevelGE1+countersLevelLE4
K:stPumpSelf:Creature:4/4/First Strike:countersLevelGE5
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/caravan_escort.jpg
End
Most of the levelers could be handled with that functionality plus SA_Restriction for checking level counters.

Actually, I may be able to do this with isPresent once isValidCard handles counters. Not major important, but something that could be really handy in general.

Brimstone Mage's abilities could be handled like this:
Code: Select all
A:AB$DealDamage|Cost$T|Tgt$TgtCP|NumDmg$1|IsPresent$countersLevelGE1.self+countersLevelLE2|SpellDescription$Brimstone Mage deals 1 damage to target creature or player.
A:AB$DealDamage|Cost$T|Tgt$TgtCP|NumDmg$3|IsPresent$countersLevelGE3.self|SpellDescription$Brimstone Mage deals 3 damage to target creature or player.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: SpellAbility_Restriction

Postby Sloth » 05 Nov 2010, 08:54

friarsol wrote:Actually, I may be able to do this with isPresent once isValidCard handles counters. Not major important, but something that could be really handy in general.

Brimstone Mage's abilities could be handled like this:
Code: Select all
A:AB$DealDamage|Cost$T|Tgt$TgtCP|NumDmg$1|IsPresent$countersLevelGE1.self+countersLevelLE2|SpellDescription$Brimstone Mage deals 1 damage to target creature or player.
A:AB$DealDamage|Cost$T|Tgt$TgtCP|NumDmg$3|IsPresent$countersLevelGE3.self|SpellDescription$Brimstone Mage deals 3 damage to target creature or player.
Yes I think this is the way to go. Adding counter support to isValidCard was planned by Rob since the very beginning (I think there is even a placeholder). I have some free time in about ten hours. If no one else has done it, I will give it a try.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 31 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 31 users online :: 0 registered, 0 hidden and 31 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 31 guests

Login Form