Author Topic: OpenRPG Macros: How strong is your Fu?  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

Tleilaxu_Ghola

  • Barbary Macaque at the Rock of Gibraltar
  • ***
  • Posts: 167
  • Wanted for consipracy to kill Pun-Pun
OpenRPG Macros: How strong is your Fu?
« on: May 26, 2009, 12:44:30 AM »
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:
Code: [Select]
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:
Code: [Select]
/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:

Code: [Select]
/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:
Code: [Select]
( (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:

Code: [Select]
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:

Code: [Select]
/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.
« Last Edit: May 26, 2009, 12:55:21 AM by Tleilaxu_Ghola »

jseah

  • Domesticated Capuchin Monkey
  • **
  • Posts: 87
    • Email
Re: OpenRPG Macros: How strong is your Fu?
« Reply #1 on: May 26, 2009, 01:28:22 AM »
Could you try programming an integer parser?

Like having 9 constants holding variables from 1 to 9 and detecting which character it is using an if-table and then converting that to the digits in an integer?

then you can just run it through the integer parser before routing that to the normal non-GVM code which does the math.  (I'm assuming that can and it's only GVM that can't)

Tleilaxu_Ghola

  • Barbary Macaque at the Rock of Gibraltar
  • ***
  • Posts: 167
  • Wanted for consipracy to kill Pun-Pun
Re: OpenRPG Macros: How strong is your Fu?
« Reply #2 on: May 26, 2009, 02:25:06 AM »
I'm not going to learn python just so I can program openRPG plugins, which is what would be required to implement what you're asking.  Working within the existing framework is generally faster than making a new framework, as long as it's possible to do what you want to, which, for the most part I have.  Reporting your spellbook en masse is something that isn't perfect with this strategy, but I've got another hack trick that lets me output the essentials for both me and my friends.  (I just use a checklist node, with a send option.  Doesn't report on the degeneracy of my prepared spells, but I think that's mostly unnecessary if that information is reported on spell cast).

jseah

  • Domesticated Capuchin Monkey
  • **
  • Posts: 87
    • Email
Re: OpenRPG Macros: How strong is your Fu?
« Reply #3 on: May 26, 2009, 09:24:51 AM »
XD  Reporting which spells you prepared today?

You can create a string with the same index as each individual spell and simply lengthen the string with markers. 

eg. fireball has an index 330

SStatus[330] = "ppu"

Means you prepared fireball 3 times.  And used it once. 

Then just change bits of the string.  Or is picking, say the 2nd character of the string, not possible?

Tleilaxu_Ghola

  • Barbary Macaque at the Rock of Gibraltar
  • ***
  • Posts: 167
  • Wanted for consipracy to kill Pun-Pun
Re: OpenRPG Macros: How strong is your Fu?
« Reply #4 on: May 26, 2009, 03:30:30 PM »
I was unaware you could create arrays in OpenRPG.  Nor was I aware that string parsing is possible.  OpenRPG macros hardly permit standard coding freedoms as far as I am aware.  If you have information to the contrary, please illustrate them more concretely.

jseah

  • Domesticated Capuchin Monkey
  • **
  • Posts: 87
    • Email
Re: OpenRPG Macros: How strong is your Fu?
« Reply #5 on: May 26, 2009, 03:42:03 PM »
Oh no no no, I'm not actually responding with any knowledge of how OpenRPG works.  Never heard of it before.  =P
 - I see it's more limited than I thought it would be >.<

Just suggesting things off the top of my head. 

You do have strings right?

I surmise you can add stuff to the ends of strings.  Can you take them off? (like chop the last few characters away)  If so, any string function (followed by an integer parser) is possible. 

I'm assuming If and For loops exist of course.  ... It can't be that bad... um... right?


Sigh... No arrays makes things difficult.  I remember programming my own 2D arrays in warcraft3 map editor.  >.<
- Stupid ending-the-for-loop-1-counter-early bug took me all of three days to find...

Tleilaxu_Ghola

  • Barbary Macaque at the Rock of Gibraltar
  • ***
  • Posts: 167
  • Wanted for consipracy to kill Pun-Pun
Re: OpenRPG Macros: How strong is your Fu?
« Reply #6 on: May 26, 2009, 07:36:00 PM »
The macro coding language is extremely limited, to put it lightly.  If it were as easy as logical statements, arrays and loops, I wouldn't need to bother making a thread on the matter.  I have plenty of normal coding experience, so casual suggestions of that nature aren't going to help me or probably anyone trying to deal with OpenRPG. 


That said, if you ARE sitting on some hawt macros, please share them.

cru

  • Donkey Kong
  • ****
  • Posts: 613
    • Email
Re: OpenRPG Macros: How strong is your Fu?
« Reply #7 on: May 27, 2009, 09:54:34 AM »
Ooh, I have some cool macros! Using the F1-F12 keys. Such as:
[Thu Jun 26 21:06:50 2008] : (627) Shagrick: Dodge THIS, motherfucker!!!
[Thu Jun 26 20:56:36 2008] : (627) Shagrick: RIP HIS ASS APART!!

and then some more in my native language. I spam these during combat.

And here's how fellow players amuse themselves:
[Thu Jun 26 20:57:06 2008] : (629) Harme: Skills: Cocksucking [1d20-20] => [17,-20] = (-3)
[Thu Jun 26 20:58:11 2008] : (626) Tissaia: OWNED!
[Thu Jun 26 20:58:12 2008] : (626) Shagrick: Ouch!

Tleilaxu_Ghola

  • Barbary Macaque at the Rock of Gibraltar
  • ***
  • Posts: 167
  • Wanted for consipracy to kill Pun-Pun
Re: OpenRPG Macros: How strong is your Fu?
« Reply #8 on: May 27, 2009, 04:02:29 PM »
Hm, you can bind macros to keys?!   That's... awesome.  Can it be multiline macros?