Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Help making a random spell macro please!

Hi everyone! I'll start out by saying I know next to nothing about coding.  I have done multiple searches for what I'd like to create, however nothing I've found really fits with what I'd like to do.  I don't know if it's best to have it be an actual API script, or if what I'm looking for can be achieved with a macro. I am in the planning process of creating a homebrew world, where something happened to all the adventurers to cause them to not be the class they were intended to be.  So players are going to choose 2 classes they are interested in playing, which do not share the same core stats.  So if player A really loves the Monk class, but also wouldn't mind playing a Wizard, then the player would get a pre-generated Wizard, with the core stats of a Monk. To make this world especially chaotic (at least for the first few levels), I basically need to create something so that spells don't always cast the way they want them to.  Say the Wizard wants to cast the cantrip Fire Bolt, well I would like something that would choose from all the cantrips in the wizard class table randomly.  Same with 1st level spells.   It would be awsome if the attack roll and damage rolls could be done with this same thing. Any ideas on how to go about doing this?  I'd rather not use the decks of cards for this, it would be really great if they could just click a button and say I'm going to cast this...and then see in the chat that they really cast a different spell. Thank you for looking at this, and any help would be super appreciated!
1492693170
Andrew C
Marketplace Creator
This reeks of Powercards but I don't know how to make them do what you want.
To choose a random thing from an arbitrary list, create a Rollable Table . If the things in the list have their own dice rolls, use the Recursive Tables script to allow them to be rolled when they come up. Does the player have any  control over which spell gets chosen?
Ideally, the player would have control over if it casts a damaging spell or a support spell, though in true chaotic fashion they could (very rarely) produce a mage hand while trying to cast fire bolt.   Thank you for the advice about the rollable table!  I will get the recursive tables script going and start putting spells into a rollable table.  Again, thank you very much!
I'm sorry I am probably missing something very simple - but how do I get the table to recognize the spells and make the rolls for them?  I put the script into my API, and I created the table and adjusted the weights so that the damaging cantrips had a higher weight than the support ones.  However I'm not sure how I can put the spell demographics (ie, the attack roll, the spell save DC, or the damage roll) into the table.  Do I have to type the information in somewhere?  Or do I have to use coding in the table to recognize that they are spells there?
1492729760
Silvyre
Forum Champion
One possibility is to write/request an API Script that determines the number of spells in each spell section and saves that number as an Attribute. For example, if your player's repeating_section for 1st-level spells (e.g. repeating_spell-1) has 10 spells, the script could create/modify an Attribute (e.g. named level1spells) and set that Attribute's value to 10. After that is set up, you could use a macro like [ Cast Random 1st-level Spell  [[ ](~repeating_spell-1_$[[d@{level1spells} - 1]]_spell) to randomly cast a 1st-level spell via a Command Button .
1492733954

Edited 1492734014
I don't know the rules of your system, but in general a table entry ("name") would be something like: Spell of Ridiculous Destruction, causes [[5d6]] points of damage. Then you'd call spell casting from a Macro or Ability something like: !rt You cast a damage spell: [[ 1t[DamageSpells] ]] Table entries are necessarily simple, so you can't format them fancy. For fancy formatting you might make each table entry an image of the spell text from the book, but then you don't get the rolls calculated for you (or you have to hover over the text to see the results). Roll Templates don't work inside Rollable Tables. Warning! When using the Recursive Tables script, I've found that if you put spaces inside any [[ ]]'s that you use in a table entry, the script will crash. For anything more complicated than this you probably need a script.
Thank you so very much!  This works perfectly, and I understand how to change things if I absolutely need to. :)  I have no need of fancy looking things, when I have no way of fixing anything I might screw up cause I have no concept of how coding works.   Again, thank you thank you thank you!