atilappl wrote:How can i implement dice rolling?
I will try to script
Urza, Academy Headmaster based on rolling a twenty-sided dice.
Unless it has been added in one of the more recent versions, no, I'm afraid die rolling isn't directly supported in Forge.
However...there
is a very nice and powerful/flexible scriptable ability called
GenericChoice that can be used to emulate die rolls to some extent.
Basically, it is used to choose one of several SubAbilities, and if you set the
AtRandom$ to
True, the choice will be made randomly, not too different from die rolls. Here's an example, a silly custom card I made quite a while ago (no idea whether it works in the current version of Forge but it should, unless something has been majorly changed since, which is of course possible...):
- | Open
- Name:Cranky Witch
ManaCost:B B
Types:Creature Human Wizard
PT:1/2
A:AB$ GenericChoice | Cost$ T | Choices$ R1,R2,R3,R4,R5,R6 | AtRandom$ True | Defined$ You | StackDescription$ SpellDescription | SpellDescription$ Roll a die. On a 1, skip your next untap step. On 2, discard a card. On a 3, lose 1 life. On a 4, gain 1 life. On a 5, put a +1/+1 counter on target creature. On a 6, draw a card.
SVar:R1:DB$ Pump | Cost$ 0 | Defined$ You | KW$ Skip your next untap step. | Permanent$ True | SpellDescription$ Skip your next untap step.
SVar:R2:DB$ Discard | Cost$ 0 | Defined$ You | NumCards$ 1 | Mode$ TgtChoose
SVar:R3:DB$ LoseLife | Cost$ 0 | Defined$ You | LifeAmount$ 1
SVar:R4:DB$ GainLife | Cost$ 0 | LifeAmount$ 1
SVar:R5:DB$ ChooseCard | Defined$ You | Cost$ 0| Amount$ 1 | Choices$ Creature | SubAbility$ PumpCounter
SVar:PumpCounter:DB$ PutCounter | Cost$ 0 | Defined$ ChosenCard | CounterType$ P1P1 | CounterNum$ 1
SVar:R6:DB$ Draw | Cost$ 0 | NumCards$ 1 | SpellDescription$ Draw a card.
SVar:RemAIDeck:True
Oracle:{T}: Roll a die. On a 1, skip your next untap step. On 2, discard a card. On a 3, lose 1 life. On a 4, gain 1 life. On a 5, put a +1/+1 counter on target creature. On a 6, draw a card.
Note that I said that GenericChoice could be used to emulate die rolls "
to some extent". There are some obvious limitations. If something tells you to roll
several dice, e.g., two 6-sided dice, you will probably end up with 6*6 different GenericChoice outcomes (rather than 6+6). Take at look at this clunky script I came up with for Lydari Elephant some time ago to see what I mean:
- | Open
- Name:Lydari Elephant
ManaCost:4 G
Types:Creature Elephant
PT:2/2
K:etbCounter:GROWTH:1
A:AB$ GenericChoice | Cost$ SubCounter<1/GROWTH> | Choices$ P11,P12,P13,P14,P15,P21,P22,P23,P24,P25,P31,P32,P33,P34,P35,P41,P42,P43,P44,P45,P51,P52,P53,P54,P55 | AtRandom$ True | Defined$ You | StackDescription$ SpellDescription | SpellDescription$ CARDNAME gains +1/+0, +1/+1 and/or +0/+1 counters in a combination that gives it +1, +2, +3, +4, or +5 to its power and toughness, each chosen individually and randomly.
SVar:P11:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 1
SVar:P12:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 1 | SubAbility$ P11
SVar:P13:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 2 | SubAbility$ P11
SVar:P14:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 3 | SubAbility$ P11
SVar:P15:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 4 | SubAbility$ P11
SVar:P21:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 1 | SubAbility$ P11
SVar:P22:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 2
SVar:P23:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 1 | SubAbility$ P22
SVar:P24:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 2 | SubAbility$ P22
SVar:P25:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 3 | SubAbility$ P22
SVar:P31:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 2 | SubAbility$ P11
SVar:P32:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 1 | SubAbility$ P22
SVar:P33:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 3
SVar:P34:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 1 | SubAbility$ P33
SVar:P35:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 2 | SubAbility$ P33
SVar:P41:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 3 | SubAbility$ P11
SVar:P42:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 2 | SubAbility$ P22
SVar:P43:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 1 | SubAbility$ P33
SVar:P44:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 4
SVar:P45:DB$ PutCounter | CounterType$ P0P1 | CounterNum$ 1 | SubAbility$ P44
SVar:P51:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 4 | SubAbility$ P11
SVar:P52:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 3 | SubAbility$ P22
SVar:P53:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 2 | SubAbility$ P33
SVar:P54:DB$ PutCounter | CounterType$ P1P0 | CounterNum$ 1 | SubAbility$ P44
SVar:P55:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 5
SVar:RemAIDeck:True
Oracle:Lydari Elephant enters the battlefield with a growth counter on it.\nRemove growth counter from Lydari Elephant: CARDNAME gains +1/+0, +1/+1 and/or +0/+1 counters in a combination that gives it +1, +2, +3, +4, or +5 to its power and toughness, each chosen individually and randomly.
Also, if there are modifiers to the die rolls, like "add +1 to the roll if your wisdom is 17, or +2 if it is 18" (typical in pen&paper roleplaying games), you are in for a world of headache trying to translate all of them to GenericChoice. Let alone something along the lines of "Add +
X to the die roll where
X is the number of cards in your hand/graveyard/library"... *shudder*
Oh, and an
important caveat! Targeting doesn't work like you expect in GenericChoice subroutines. More specifically, it doesn't work
at all. (Again, unless it has been changed in a relatively recent version.) You will need to use ChooseCard instead (see the Cranky Witch example above, die roll 5). Which is kind of similar, yet
isn't the same! For example, "Protection from color" means, among other things, that the card can't be
targeted by a spell or ability of a specific color...but, AFAIK, when using
ChooseCard, a spell of that color can still affect (i.e., effectively "target") a card that is supposed to have protection from the color.
As for
Urza, Academy Headmaster ...wow, that is one tough cookie. Looking briefly, I didn't notice anything that outright
couldn't be done, but wow, it would be an insanely immense task! Comparable to scripting 50 or so individual cards. Not to mention that some of the die roll results involve something like "flip a coin 5 times...". Again, that
can be scripted, but that in itself translates to quite a few script lines...
And if you succeed, you will have one record-breakingly massive script file! Probably 50kb or more.