D&D 4E Power Macro API

Framework(s) for D&D 4e, including Veggiesama's.

Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice

User avatar
TK
Giant
Posts: 162
Joined: Fri Jun 27, 2008 12:02 am

Re: D&D 4E Power Macro API

Post by TK »

Really? It shows up as diamonds for me. I remember vaguely seeing a similar in someone else's thread (DeviantNull's I think, but they all run together in my head some times). I'll see if I can find what they did to fix the problem, but in the mean time if anyone else knows what the resolution is then please speak up.

Found it:
mindshadow2k wrote:First of all I just want to commend you on your work, it is absolutely jaw dropping and I am going to adopt it in my game.

I use a mac with Firefox as my default browser and in looking at a few of the symbols that you have used, they don't translate (♦ and &dagger for example). I would suggest using the numerical code equivalent to ensure there is better cross platform support

diamonds = ♦
dagger = †
up arrow = ↑

I looked here to get the numerical equivalent:
http://www.1stsitefree.com/special_characters.htm
or
http://webdesign.about.com/od/localizat ... s-punc.htm
I'll update the tokens using the number code shortly

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: D&D 4E Power Macro API

Post by Azhrei »

This page has all of the HTML entities that I found on the W3C web site. In addition, users can test to see if their browser works properly by visiting the page, as the symbol name is used to display the symbol.

User avatar
TK
Giant
Posts: 162
Joined: Fri Jun 27, 2008 12:02 am

Re: D&D 4E Power Macro API

Post by TK »

Thanks to you guys for pointing it out and helping me fix, the files are now fixed. Links are the same, but posted again since the page changed.

TKLink: http://dl-client.getdropbox.com/u/36446 ... Link.rptok

TKText: http://dl-client.getdropbox.com/u/36446 ... Text.rptok

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: D&D 4E Macros, Properties, and Definitions (Oh my)

Post by Craig »

TK wrote:The diamonds are intentional, since that makes them match the formatting in the source material. If enough people want a change I can create a similar token without the diamonds. Personally I think they look nice.

Edit: A sample usage macro. It's pretty basic, but it took me a while to figure out the new macro functionality, so hopefully it helps give people ideas.

Code: Select all

[macro("Basic Melee Attack@Lib:TKText"):""] // Prints the power text to the screen
Or alternatively there should be a way to return the string to assign it to a variable. (I haven't quite figured out how to do this part yet, so the code below doesn't work yet, but I'll update once I get it working.)

Code: Select all

[H: mystring=""]
[H: myString = evalMacro('[macro("Basic Melee Attack@Lib:TKText"):""]')]
{mystring}
Its worth looking at either one of the PDF files in the Demon Campaign Thread as they contain a section on user defined functions which may suggest other alternatives to you.

User avatar
TK
Giant
Posts: 162
Joined: Fri Jun 27, 2008 12:02 am

Re: D&D 4E Power Macro API

Post by TK »

Thanks Craig, that PDF has some really good info in it, and I think I may finally understand JSON objects now. I'm going to take a shot at defining an attack object and a damage object so that people can take a look and see if I am missing something.

Supporting Objects
These are complex types used below
SMMA (Stat Modifier Multiplier Array)
JSON Array, Length 6, all items are numbers.
This is a JSON Array of length 6 which is meant to be multiplied 1-to-1 by an array of stat modifiers. The order is always Str, Con, Dex, Int, Wis, Cha. For example, if there was a power that required you to add your dexterity modifier and your charisma modifier, the SMMA for that part of the power would be [ 0, 0, 1, 0, 0, 1]
Assuming that the character using this power had a stat modifier array of [1, 1, 4, 2, 1, 3] then the resulting bonus would be (1*0)+(1*0)+(4*1)+(2*0)+(1*0)+(3*1)=7

Defense Array
JSON object, each key has an integer. Keys: vsAC, vsFort, vsRef, vsWill
This JSON Array of length 4 has a key for each of the possible defenses. If an attack targets a defense, it's key should be >0, if not then it should be 0. For now I am planning to just use a 1 or a 0, but more more complicated powers it may be necessary to put values other than 1, so checks should be made against >0 rather than =1.



Attack Object
JSON Object, key list as follows
Name: type string, the name of the power which the attack is for
StatBonus: type SMMA(see above)
Bonus: type string, a string that the dice engine can evaluate, added as a bonus to the attack
Vs: type Defense Array(see above)
Weapon: type integer, 0 if no weapon used, >1 if weapon used
Implement: type integer, 0 if no implement used, >1 if weapon used
DamageTypes: JSON string Array of any length, each element is a damage keyword the power has (example ["Fire"]) may be empty
PowerSource: JSON string Array of any length, each element is a power source keyword
Keywords: JSON string Array of any length, each element is a keyword that applies to the power, other than accessory keywords, damage keywords, or power keywords

Damage Object
JSON Object, key list as follows
Name: type string, the name of the power for which this damage is for
BaseDamage: type string, a string that the dice engine can evaluate, represents the base damage a power does before things like stat modifiers
WeaponDice: type integer >=0, the number of times to apply weapon damage (the number in front of [W])
StatBonus: type SMMA(see above)
Weapon: type integer, 0 if no weapon used, >1 if weapon used
Implement: type integer, 0 if no implement used, >1 if weapon used
DamageTypes: JSON string Array of any length, each element is a damage keyword the power has (example ["Fire"]) may be empty
PowerSource: JSON string Array of any length, each element is a power source keyword
Keywords: JSON string Array of any length, each element is a keyword that applies to the power, other than accessory keywords, damage keywords, or power keywords

Lindharin
Dragon
Posts: 668
Joined: Sat Apr 21, 2007 4:51 pm

Re: D&D 4E Power Macro API

Post by Lindharin »

Interesting approach with the SMMA object, I need to let that one percolate.

Are you thinking about having this as a community standard for powers that we could all agree on, and then use in various frameworks and custom campaigns? If so, I think that could be very cool. I've been considering suggesting it, but haven't gotten around to it.

It would be very nice to have a communal power definition / execution framework, that could then be plugged into any of the other frameworks that provide character sheets, etc. I think it would actually be relatively straight-forward to reach some consensus on the power structure, since it is a fairly objective goal with known rules. The subjective bits (like what the actual power creation screen or chat output looks like) could be independent, as long as the underlying power definition JSON object met the standard.

Is that what you are thinking about?

What about text or informational fields? I currently have text fields for flavor text, non-damage effects, effects on miss only, sustain action (if any) and sustain effects, and an attack description and hit description to identify special notes about that attack. Also range (and area for bursts/blasts). Not all powers will have values in all of those, of course.

It might be necessary to define a compatible standard for weapons/implements too, since weapon/implement stats feed into the attack data for almost all powers.

User avatar
TK
Giant
Posts: 162
Joined: Fri Jun 27, 2008 12:02 am

Re: D&D 4E Power Macro API

Post by TK »

Lindharin wrote:Are you thinking about having this as a community standard for powers that we could all agree on, and then use in various frameworks and custom campaigns?
In a way, but I only want to define specific small parts so that people can use it in any way they want.
Lindharin wrote: It would be very nice to have a communal power definition / execution framework, that could then be plugged into any of the other frameworks that provide character sheets, etc. I think it would actually be relatively straight-forward to reach some consensus on the power structure, since it is a fairly objective goal with known rules. The subjective bits (like what the actual power creation screen or chat output looks like) could be independent, as long as the underlying power definition JSON object met the standard.

Is that what you are thinking about?
It is definitely a good goal, but for the time being I want to start small so that people don't need to change as much. I'm not creating an object to represent a power, just some of the individual pieces of them. Plus, I want to see what works and what doesn't before trying to represent something as complicated as a power.

User avatar
TK
Giant
Posts: 162
Joined: Fri Jun 27, 2008 12:02 am

Re: D&D 4E Power Macro API

Post by TK »

I think it will help to add in a string for the attack/damage text ("Strength vs. AC" for example)

Attack Object
JSON Object, key list as follows
Name: type string, the name of the power which the attack is for
RollText: type string, The text in the power that the roll encapsulated
StatBonus: type SMMA(see above)
Bonus: type string, a string that the dice engine can evaluate, added as a bonus to the attack
Vs: type Defense Array(see above)
Weapon: type integer, 0 if no weapon used, >1 if weapon used
Implement: type integer, 0 if no implement used, >1 if weapon used
DamageTypes: JSON string Array of any length, each element is a damage keyword the power has (example ["Fire"]) may be empty
PowerSource: JSON string Array of any length, each element is a power source keyword
Keywords: JSON string Array of any length, each element is a keyword that applies to the power, other than accessory keywords, damage keywords, or power keywords

Damage Object
JSON Object, key list as follows
Name: type string, the name of the power for which this damage is for
RollText: type string, The text in the power that the roll encapsulated
BaseDamage: type string, a string that the dice engine can evaluate, represents the base damage a power does before things like stat modifiers
WeaponDice: type integer >=0, the number of times to apply weapon damage (the number in front of [W])
StatBonus: type SMMA(see above)
Weapon: type integer, 0 if no weapon used, >1 if weapon used
Implement: type integer, 0 if no implement used, >1 if weapon used
DamageTypes: JSON string Array of any length, each element is a damage keyword the power has (example ["Fire"]) may be empty
PowerSource: JSON string Array of any length, each element is a power source keyword
Keywords: JSON string Array of any length, each element is a keyword that applies to the power, other than accessory keywords, damage keywords, or power keywords

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: D&D 4E Power Macro API

Post by DeviantNull »

A couple of thoughts...

SMMA is a decent way to do abilities for powers. Though I store all the ability score properties in their own array, as long as the array is always the same order, cross indexing would work.

Overall for attack objects I think you're on a good track but you've combined power features and attack features. You might think about splitting them apart. An attack object should just be the object that holds the information for the attack itself, which would include damage, independent from the power. An attack object has no need of a damage type, powersource, or keywords. Those are features of the Power. The Power Object then could hold more then 1 attack object to allow for handling of multiple independent attack objects.

Also, might think about adding a multi-target value to Attacks given the way true multi-attacks are handled with 1 damage roll vrs many attack. You could still use the same Attack Object and just loop it multiple times, but the damage output needs to be suppressed on extra iterations.

That way an Attack Object would contain aspects of your original Attack Object plus the Damage Object and contain all the information for exactly 1 attack output line. A Power Object would then contain all the information for the specifics of the power and could contain multiple Attack Objects.

For attack objects, statbonus and bonus are almost exactly how I do things already.

Vs is a trivial. I currently store it as a text (or number, can't recall) string for just 1 value. I don't think any attack targets more then 1 defense, but it's trivial to just run it through a switch to read out the right output.

Weapon and Implement I'm a little more iffy on. This is a tricky one because the attack needs to know where to get the values for the weapon, so a true/false doesn't seem like it covers it well enough. Unless I'm over looking something. Seems like there needs to be a standardized way of handling weapons as well, especially since powers can be mixed and matched with weapons.

Base Damage and WeaponDice are almost how I already do things except I just store it all as one value and then run it through several checks. If the Damage is empty it just uses the weapon. If it's a dice code it uses that. If it's a single number it disassembles the dice code and multiples it and then reassembles it. For execution, I could have just called the damage value multiple times, but that doesn't get me the nice display output for the power info when a 2d6 weapon becomes 4d6 on a 2W power, it would look more like 2d6+2d6. But ultimately, that doesn't effect the underlying object and is more of an output thing, so the proposed storage should work.

For Powersource, keyword, and damagetypes, storing them as arrays rather then just text strings is an interesting idea. I can see a reason for doing this, to allow for automation of some game mechanics. That falls outside my desired goals, I personally don't want that stuff automated because it becomes more difficult to adjudicate and undo if need be. Also becomes something of an input issue as well. A text string is easy to enter. Lists become more bothersome for me, but with the new JSON stuff I haven't tried to find out if HTML selection lists work with multiple selections. Doing them as checkboxes makes it take up quite a bit of space... I'm going to need to try a couple of things.

User avatar
TK
Giant
Posts: 162
Joined: Fri Jun 27, 2008 12:02 am

Re: D&D 4E Power Macro API

Post by TK »

DeviantNull wrote: Overall for attack objects I think you're on a good track but you've combined power features and attack features. You might think about splitting them apart. An attack object should just be the object that holds the information for the attack itself, which would include damage, independent from the power. An attack object has no need of a damage type, powersource, or keywords. Those are features of the Power. The Power Object then could hold more then 1 attack object to allow for handling of multiple independent attack objects.
The way I was looking at it is that an attack object should be something that a character handler can receive, and should contain all the information that the handler would need in order to execute the attack (add in stat bonuses, weapon bonuses if necessary, etc). Same theory for damage objects.
I also initially started with the assumption that damage objects are separate from attack objects, which looking back may have been a bad assumption, I'll think of a good way to tie them together.
DeviantNull wrote: Also, might think about adding a multi-target value to Attacks given the way true multi-attacks are handled with 1 damage roll vrs many attack. You could still use the same Attack Object and just loop it multiple times, but the damage output needs to be suppressed on extra iterations.
Good point, I think some sort of target field should be added in.
DeviantNull wrote: That way an Attack Object would contain aspects of your original Attack Object plus the Damage Object and contain all the information for exactly 1 attack output line. A Power Object would then contain all the information for the specifics of the power and could contain multiple Attack Objects.
The main reason that I went about keeping attack and damage separate is to handle some of the more complicated powers, but maybe there's a better way.
DeviantNull wrote: Weapon and Implement I'm a little more iffy on. This is a tricky one because the attack needs to know where to get the values for the weapon, so a true/false doesn't seem like it covers it well enough. Unless I'm over looking something. Seems like there needs to be a standardized way of handling weapons as well, especially since powers can be mixed and matched with weapons.
Definitely an area for improvement, perhaps different codes for melee, ranged, hybrid, main hand/offhand. I'll need to think more on this one.
DeviantNull wrote: For Powersource, keyword, and damagetypes, storing them as arrays rather then just text strings is an interesting idea. I can see a reason for doing this, to allow for automation of some game mechanics. That falls outside my desired goals, I personally don't want that stuff automated because it becomes more difficult to adjudicate and undo if need be. Also becomes something of an input issue as well. A text string is easy to enter. Lists become more bothersome for me, but with the new JSON stuff I haven't tried to find out if HTML selection lists work with multiple selections. Doing them as checkboxes makes it take up quite a bit of space... I'm going to need to try a couple of things.
For me, I'm not really thinking much about input issues since I'm automating the generation of every macro created.

Anyway, thanks for your feed back, it's very helpful to me.

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: D&D 4E Power Macro API

Post by DeviantNull »

TK wrote:The way I was looking at it is that an attack object should be something that a character handler can receive, and should contain all the information that the handler would need in order to execute the attack (add in stat bonuses, weapon bonuses if necessary, etc). Same theory for damage objects.
I also initially started with the assumption that damage objects are separate from attack objects, which looking back may have been a bad assumption, I'll think of a good way to tie them together.
I agree in that the attack object should contain all the information that a handler would need. I"m just seeing a different hierarchy and grouping:

Power Object - contains specific information about a single power such as Type, Action Use, Keywords, Range, Flavor, Effect, Sustain, and any other misc factors.

Attack Object - contains all the information needed for a handler to execute 1 single attack from to-hit to damage. A Power Object could contain 1 or more Attack Objects that make up it's attack routine.

The weird spot is Hit/Miss effects. I'd need to look over powers again, and lord only knows what PHBII does to it (I haven't had a time to really look at it), but this could fall under Power or Attack. Hit/Miss seems to be a generalized effect tied to the power more then the attack itself, but then Prismatic Beams goes and screws that up. Personally, I'd prefer Attack Objects to just hold the mechanical info needed to process the attack/damage and then leave Hit/Miss to power.
TK wrote:Anyway, thanks for your feed back, it's very helpful to me.
NP! It's given me a few things to consider as well, mainly seeing if I can't implement something along these lines. It's a much better system then what I'm currently using which is 90% a hold over from when all I had to work with StrProps. Now that imbeded JSON exists it opens up more options.

One thing that occurred to me about you SMMA array is how to handle powers that allow an either/or option for abilities. Rangers are the big one, since they can use Dex or Str for their attacks. While most will focus on one over the other they still can use the powers either way. I think there needs to be some option available to build a power that allows a choice, otherwise you have to build the power itself twice, once for Str and once for Dex.

I'm not quite sure how to handle that one.

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: D&D 4E Power Macro API

Post by jfrazierjr »

DeviantNull wrote: One thing that occurred to me about you SMMA array is how to handle powers that allow an either/or option for abilities. Rangers are the big one, since they can use Dex or Str for their attacks. While most will focus on one over the other they still can use the powers either way. I think there needs to be some option available to build a power that allows a choice, otherwise you have to build the power itself twice, once for Str and once for Dex.

I'm not quite sure how to handle that one.
Why are you not setting this on the weapon level, the weapon itself is the determining factor if the power can use said weapon with the power. Perhaps with the weapon being the primary property with the power as an optional override which will be used IF SET.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: D&D 4E Power Macro API

Post by DeviantNull »

jfrazierjr wrote:Why are you not setting this on the weapon level, the weapon itself is the determining factor if the power can use said weapon with the power. Perhaps with the weapon being the primary property with the power as an optional override which will be used IF SET.
That's a pretty good idea, all melee and thrown heavy are Str and ranged are Dex. This would solve the ranger issue and is a darn elegant solution.

I can't think of any powers that fall outside this structure. There any powers out that that would pick between two non-standard ability scores?

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: D&D 4E Power Macro API

Post by jfrazierjr »

DeviantNull wrote:
jfrazierjr wrote:Why are you not setting this on the weapon level, the weapon itself is the determining factor if the power can use said weapon with the power. Perhaps with the weapon being the primary property with the power as an optional override which will be used IF SET.
That's a pretty good idea, all melee and thrown heavy are Str and ranged are Dex. This would solve the ranger issue and is a darn elegant solution.

I can't think of any powers that fall outside this structure. There any powers out that that would pick between two non-standard ability scores?
Well.. there ARE some that do... Swordmage comes to mind and even moreso with the Intelligent Blademaster feat. It still needs to be on the weapon... but should not be hard coded to a "weapontype" keyword so to speak....
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
TK
Giant
Posts: 162
Joined: Fri Jun 27, 2008 12:02 am

Re: D&D 4E Power Macro API

Post by TK »

DeviantNull wrote: The weird spot is Hit/Miss effects. I'd need to look over powers again, and lord only knows what PHBII does to it (I haven't had a time to really look at it), but this could fall under Power or Attack. Hit/Miss seems to be a generalized effect tied to the power more then the attack itself, but then Prismatic Beams goes and screws that up. Personally, I'd prefer Attack Objects to just hold the mechanical info needed to process the attack/damage and then leave Hit/Miss to power.
...
One thing that occurred to me about you SMMA array is how to handle powers that allow an either/or option for abilities. Rangers are the big one, since they can use Dex or Str for their attacks. While most will focus on one over the other they still can use the powers either way. I think there needs to be some option available to build a power that allows a choice, otherwise you have to build the power itself twice, once for Str and once for Dex.

I'm not quite sure how to handle that one.
So my original idea was to have the power macro pop up a frame with the power text (or post it to the chat if people prefer) and have links on each of the attack rolls and damage rolls (and eventually other stuff like status effects and healing). Clicking an attack link passes an attack object to the character handler which supplies the necessary character information to generate the final attack roll with the relevant modifiers. This would let players easily pick which attack and/or damage roll(s), particularly for some of the more complicated powers.

Post Reply

Return to “D&D 4e Frameworks”