I'm not sure if this is a great place to put this kind of thread, but I figure there may be a D&D OpenRPG user or two on these boards and more than likely one of you has tried to pimp out some macro for an optimized character. If you have, you'll notice that OpenRPG is a bitch and doesn't really scale well with the most mundane things. But I've created a few hacks here and there. I'll post a couple of my more salient tricks, lemme know if you've got better ones.
A Wizard's Spell Book: Recording, reporting, and tracking spell usage with respect to prepared spells.
Ingredients: Using OpenRPG 1.7.7. I believe 1.6.3 also works. There is a plugin called "Game Variable Manager" or something of the sort. The command to use it is /gvm. Anyways, this plugin allows you to store text variables and set them in macros. That's an important piece of functionality missing from the standard OpenRPG setup. Unfortunately, however, GVM doesn't allow you to perform arithmetic on it's variables. You call GVM variables like this:
macro command:
/gvm set VARNAME=VARTEXT // This makes a variable VARNAME and stores the string "VARTEXT" in it
Text with $VARNAME in the middle // This will inject the text stored in VARNAME into the line
macro output:
Text with VARTEXT in the middle
Note: C++ style comments don't actually work in OpenRPG to my knowledge. Remove those if you're actually coding this.
So how do you track spells with this? Well, this is the best method I came up with:
- I recommend creating a self-consistent naming scheme that will allow you to store many different spells with minimal change to variable name; for example I store spell variables with a 4 digit numbering scheme suffixed with a 3 letter designation for the variable role. More on variable roles in the next few points:
- Create a variable that intializes a variable to store the number of preparations of a given spell. I designate this with a "prp" at the end of the spell number ID.
- Create a variable that stores the number of uses for a given spell. I designate this with a "use" at the end of the spell number ID.
- Create a variable that stores the output string. I designate this with a "out" at the end of the spell number ID.
So for spell 0107, I have the following variable intialization:
/gvm set 0107prp=0
/gvm set 0107use=0
/gvm set 0107out=( ( $0107prp ) - ( $0107use ) )
Note: white space seems to be important. The above spacing works for me. Other spacing (or lack thereof) has not worked for me.
Now, it's important to note that there's absolutely nothing "dynamic" about this set up at all. 0107out won't update when you change 0107prp or 0107use at a later date. That means every time you change either prp or use tagged variables, you need to update the out variable by reinitializing it as I show above. So, for a given spell I have 2 macros + a cast macro. First, I have a macro that sets the prp, use, and out variables as shown above. Second, I have a macro that "iterates" the preparation variable (prp) by 1 for every button press. This lets me open my spell book and simply push a button if I want to prepare that spell once. I push it twice to prepare it twice. Simple enough, right? Here's how that's implemented:
/gvm set 0107prp=$0107prp + 1
Similarly, in my cast macro, I have the following to record usage of a spell:
/gvm set 0107use=$0107use + 1
/gvm set 0107out=( ( $0107prp ) - ( $0107use ) )
Note: I updated "out" in the cast macro. That's because everytime I cast, I report how many remaining preparations of that spell I have. More on that later.
After, say 3 preparations of spell 0107 and 2 uses, this is what the output variable will store:
( (0 + 1 + 1 + 1 ) - (0 + 1 + 1 ) )
Now, you can TRY to keep that private and read your spell preps yourself and track them that way. But I find this to be obfuscating at the least. Instead, what I do is simply output the remaining number of spell preparations I have for a given spell right into the spell-cast macro. That macro also has all sorts of checks, like ASF check, defensive casting check, taint checks, announces the spell name, etc. Here's how you output a pretty number:
macro:
Your_Char_Name has [Q1 $0107out -1] preparation(s) of !@Your_Char_Name::0107name@! remaining.
output (suppose spell ID number 0107 refers to Mage Armor and your character's name is "Jessica"):
"Jessica has 1 preparation(s) of Mage Armor remaining.
Note: pretty printing the number is a little wonky. I've found that using the [Q1 $varname -1] evaluates the text without any fuss. Attempting something like [Q$varname] has given me trouble. So it's just safer to go with the time honored mathematical trick of adding and subtracting the same number from an equation to get something new.
This coding scheme can be extended easily to psionics, spontaneous casting, or Tome of Battle maneuvers I've found. Prepared spell casting remains the most difficult, time consuming, and variable intensive mechanism to code in my personal experience.
EDIT: I want to make the following abundantly clear. Math is not possible with GVM variables. Don't even try it; you'll waste possibly hours doing so. Just to show you what I mean:
/gvm set x=5
/gvm set y=3
/gvm set z=$x-$y
$z
What you might think is the output:
2
The real output:
5-2
Even this doesn't work:
/gvm set x=5
/gvm set y=3
/gvm set z=[Q1 $x-$y -1]
$z
What you might think is the output:
2
The real output:
[Q1 5-3 -1]
In other words, numerical evaluation can only occur if it's printed out to the screen. You cannot get it to evaluate internally before printing.