Help for a D&D programmer?

theoremtank

First Post
Hi, recently been getting into writting small D&D utility programs and have run across a nagging problem.

I have been able to derive mathematical formulas for a variety of tables in the Player's Handbook, but there are still a couple that are nagging me. For instance, the wizard's spells per day table. I wish to come up with a formula that will generate the spells per day for each level based off of the wizards level as input, yet I have been unable to come up with anything very efficient. So my question is, do you programmers out there think its just better to write a file with this table in it and have the program access the file for info, or is it better to use a mathematical formula to do this.

Thanks
 

log in or register to remove this ad


You *have* to do specific configuration for each class.

The fact that clerics, wizards and sorcerors all have different results at the same levels, shows that there is no formula that's level based.
It becomes a lot more obvious when you look at other classes like Asn and Pal.

It's not trivial, but you can get a formula for bonus spells based on ability (eg. Cha for Sor, Int for Wiz), which you then add to the class specific result.

Regards,
 

Yes, I came up with a formula (or formulas) to generate the bonus spells per day based off of ability modifiers. If I recall right it is something like

Bonus_Spells( Modifier, Spell_level ) =
ceiling( (Modifier - (Spell_Level))/4 )

I really understand now that putting the other spell progression tables in files is the way to go.
Thanks
 
Last edited:

Pah, Luke! Spell per day formula impossible? It's just a little tricky. (The below code is JScript, and includes all formatting. It would be shorter otherwise.)

Code:
 if(Wiz>0&&Int>=10) {
  spell=new Array(4,0,0,0,0,0,0,0,0,0);
  if(Wiz==1) spell[0]=3;
  for(i=1;i<=9;i++) {
   spell[i]=Math.max(0,Math.floor((Int-2-2*i)/8));
   k=new Number(Wiz-2*i);
   k=k+2;
   if(k>0) spell[i]=spell[i]+1;
   if(k>1) spell[i]=spell[i]+1;
   if(k>3) spell[i]=spell[i]+1;
   if(k>6) spell[i]=spell[i]+1;
   if(k<1) spell[i]=0;
   if(school!=''&&spell[i]>0) spell[i]=spell[i]+1;
  }
  if(Wiz>=19) spell[9]=spell[9]+1;
  if(Wiz>=20) spell[8]=spell[8]+1;
  spellL=spellL+p+''+i1+'Wizard Spells Prepared'+i2+' (';
  for(i=0;i<=9;i++) {
   if(spell[i]>0) {
    spellL=spellL+spell[i];
    spellL=spellL+'/';
   }
  }
  spellL=left(spellL,spellL.length-1)+'): ';
  if(Math.floor(Wiz/2+.5)>Int-10&&Int<19) spellL=spellL+'  (This character cannot cast level '+(Int-9)+' spells or higher; higher-level spell slots may be used for lower-level spells, possibly metamagic.)';
  spellL=spellL+'</p>\n';
 }

The formula for bonus spells is included above, and is much simpler: (Attribute - 2 - 2 * spell level) / 8.
 


And for the foreign language speakers around us:

"not trivial" <> "impossible"
int( "not trivial" ) = int( "just a little tricky" )

'not trivial' != 'impossible'
Math.floor( 'not trivial' ) == Math.floor('"just a little tricky' )

Of course, Luke, I wasn't talking about your 'trivial' comment - the formula for bonus spells by attribute is trivial. I was talking about your comment that there is no formula for spells by level; that was the big formula I posted.
 
Last edited:

CRGreathouse said:
I was talking about your comment that there is no formula for spells by level; that was the big formula I posted.

With you now. Of course this only works for one class, and you need a different one for each class - hence you may as well use configuration.
I may change my mind when I get to see Epic, since your formula will presumably work for *any* level... Do you have some kind of confirmation that the sequence follows official guidelines beyond Lev20 ?

Please don't mind my "help", theoremtank. ;)
 

The past-20 rules are:
1. Different
2. Not OGC

at the moment. The only formula of true importance is the attribute bonus spell formula.
 

Luke said:
Of course this only works for one class, and you need a different one for each class - hence you may as well use configuration.

The posted formula was for the wizard, one of the hardest to quantify. The sorcerer is much easier, as a simple glancxe will tell you. The only reall hard one is the bard.
 

Remove ads

Top