Widget HTML Atas

Card Scripting

Card scripting is cool. Instead of having to program cards using Java, which is usually very long and over 100 lines of code, card scripting is shockingly short. Probably 95% of all cards in Forge are scripted.

To look at a specific card’s scripting: first go to the forge folder, then res, then cardsfolder, and unzip “cardsfolder.zip”. Cards like Jace, the Mind Sculptor do not have any scripting and the text file only holds basic information about the card such as its name, cost, card types and starting loyalty.

Shock is always my favorite example.

Name:Shock
ManaCost:R
Types:Instant
Text:no text
A:SP$ DealDamage | Cost$ R | Tgt$ TgtCP | NumDmg$ 2 | SpellDescription$ CARDNAME deals 2 damage to target creature or player.
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/shock.jpg
SetInfo:8ED|Common|http://magiccards.info/scans/en/8e/222.jpg
SetInfo:7ED|Common|http://magiccards.info/scans/en/7e/219.jpg
SetInfo:STH|Common|http://magiccards.info/scans/en/sh/98.jpg
SetInfo:9ED|Common|http://magiccards.info/scans/en/9e/220.jpg
SetInfo:10E|Common|http://magiccards.info/scans/en/10e/232.jpg
SetInfo:6ED|Common|http://magiccards.info/scans/en/6e/206.jpg
SetInfo:M12|Common|http://magiccards.info/scans/en/m12/154.jpg
SetInfo:ONS|Common|http://magiccards.info/scans/en/on/227.jpg
Oracle:Shock deals 2 damage to target creature or player.
End

Obviously there is a fair about of information here such set information, where each card picture is located as well as its rarity.

A:SP$ DealDamage | Cost$ R | Tgt$ TgtCP | NumDmg$ 2 | SpellDescription$ CARDNAME deals 2 damage to target creature or player.

This is the “scripting” part that creates the card Shock. The scripting restricts the targets to creatures or players, specifies the mana cost, and has some text to show the player.

My 2nd favorite example is Elvish Piper. He isn’t a powerhouse but he is a fun card to use.

Name:Elvish Piper
ManaCost:3 G
Types:Creature Elf Shaman
A:AB$ ChangeZone | Cost$ G T | Origin$ Hand | Destination$ Battlefield | ChangeType$ Creature | ChangeNum$ 1 | SpellDescription$ You may put a creature card from your hand onto the battlefield.
PT:1/1
SVar:Rarity:Rard

Elvish Piper’s activated ability is far more complicated than Shock’s. The cost is listed as “G T” which seems to mean “1 green mana” and “tap this card”. “Origin$ Hand” means that the creature card is taken from the player’s hand.

Name:Shivan Dragon
ManaCost:4 R R
Types:Creature Dragon
PT:5/5
K:Flying
A:AB$ Pump | Cost$ R | NumAtt$ +1 | SpellDescription$ CARDNAME gets +1/+0 until end of turn.

Shivan Dragon’s pump ability is a common effect, “R: Shivan Dragon getes +1/+0 until end of turn”. Any card with a similar ability can be scripted as well.

Name:Shivan Meteor
ManaCost:3 R R
Types:Sorcery
A:SP$ DealDamage | Cost$ 3 R R | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumDmg$ 13 | SpellDescription$ CARDNAME deals 13 damage to target creature.
K:Suspend:2:1 R R

Shivan Meteor is fairly straightforward except that it also has suspend. Shivan Meteor regularly costs 3RR but can be suspended (and played) in 2 turns for 1RR. The scripting for suspend is simple since other parts of Forge handle the actual implementation.

Name:Akroma, Angel of Wrath
ManaCost:5 W W W
Types:Legendary Creature Angel
PT:6/6
K:Flying
K:Vigilance
K:First Strike
K:Trample
K:Haste
K:Protection from red
K:Protection from black
SVar:Rarity:Rare

Even though Akroma has a ton of text, all of the text is standard keywords. Cards with activated abilities require more scripting than Akroma.

Name:Day of Judgment
ManaCost:2 W W
Types:Sorcery
A:SP$ DestroyAll | Cost$ 2 W W | ValidCards$ Creature | SpellDescription$ Destroy all creatures.

Name:Wrath of God
ManaCost:2 W W
Types:Sorcery
A:SP$ DestroyAll | Cost$ 2 W W | ValidCards$ Creature | NoRegen$ True | SpellDescription$ Destroy all creatures. They can't be regenerated.

Obviously these two cards are almost clones of each other. Wrath of God is slightly more powerful because creatures can’t regenerate. Obviously Wizards of the Coast thought that Wrath of God was unbalanced and then created Day of Judgment. The Wrath of God scripting includes “NoRegen$ True” which is a minor point but very important. Since Wrath of God is scripted, its mirror Damnation is also scripted and has a different mana cost of 2BB.

Scripting is great and it allows non-programmers to add new cards. The scripting has gotten more complicated and is now a “little language” that does one thing well: create Magic cards.

Average blogger,
mtgrares

p.s.
Eons long ago while I playing Magic Online, I remember using my Elvish Piper to play Darksteel Colossus (11, 11/11, creature, indestructible, trample). Because they were expensive cards, I only had one copy of each card so I was very happy when I actually got to use them. :+)

Search Results Computer Programing, technological, Data Appears, RiskTool, games, memory, MIPS Computer Programing, technological, Data Appears, RiskTool, games, memory, MIPS