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

ChatSetAttr - Modifying a weapon attack/damage

Good morning, Is there a way to modify a weapon attack and damage using ChatSetAttr?  I know what the attack and damage attributes are, but how do you know which weapon you are modifying? Thanks for any help!
1698071879

Edited 1698071959
Yes. You have to identify the attack based on its 'repeating number'. This is based on the order of the items in each section, and the numbering starts at '0', so the first item is $0, the second is $1, and so on. ( Here's a similar related post .) For NPCs a ChatSetAttr command looks like this: !setattr --sel --repeating_npcaction_$0_attack_tohit|5 --repeating_npcaction_$0_attack_target|One Target --repeating_npcaction_$0_attack_damage|1d8+5 --repeating_npcaction_$0_attack_damagetype|bludgeoning For PCs the damage is @{selected|repeating_attack_$0_dmgbase} And for PCs the attack is several possible values that are calculated when the button is pressed on the sheet, and not a single attribute: Atk Base: @{selected|repeating_attack_$0_atkattr_base} Atk Mod: @{selected|repeating_attack_$0_atkmod} Atk Prof Flag: @{selected|repeating_attack_$0_atkprofflag} Then there is the Global Attack Modifier as well: @{selected|repeating_tohitmod_$0_global_attack_active_flag}
Oh, ok.  Thanks.  So what happens if the order is changed?  Does the Number follow or does the macro need to be updated?
The macro would need to be updated.
1698082372
timmaugh
Forum Champion
API Scripter
If you use Fetch to get the attribute, though, you wouldn't have to change it. Fetch can work right in the ChatSetAttr line, and it offers a way to get the name of the particular sub-attribute of a repeating list entry via criteria you supply. For instance, on a 5E character sheet, if an entry in the attack list is named "Spear", then the sub-attribute atkname contains the text "Spear". The entire entry for the "Spear" attack occupies a particular place in the list ($0, $1, etc.), so if you want to know the dmgbase sub-attribute where the atkname sub-attribute is "Spear" and occupies position $1, then you want the dmgbase sub-attribute for row $1. The problem is,  as you note, you can't always count on the row number being what it was last time. The order can be changed. Fetch gets around that by going through the reference from the criteria you supply... so instead of having to know the number (and having to update the number if the row order ever changes), you can instead as for the dmgbase sub-attribute where the atkname sub-attribute is Spear: *(Character Name.attack.[atkname = Spear].dmgbase) That would get you the value in the sub-attribute. But what you want is some version of the name, but that's OK, because this Fetch construction offers a few data points you can pull: FETCH CONSTRUCTION | EXAMPLE RETURN ===========================================================|================================================= *(Character Name.attack.[atkname = Spear].dmgbase) | 1d6 *(Character Name.attack.[atkname = Spear].dmgbase.name) | repeating_attack_-NZd9mlhGN68MUMxQSMZ_dmgbase *(Character Name.attack.[atkname = Spear].dmgbase.name$) | repeating_attack_$4_dmgbase *(Character Name.attack.[atkname = Spear].dmgbase.row$) | $4 You could use either the name or the name$ version in the ChatSetAttr line in place of hard-coding the name, and then you would no longer have to update the command line if the order of entries in the repeating list were to change at some point. You can give it a try: code up the command line using an agnostic Fetch construction and run the command line to show that it works; then reorder your list entries and run the command line again... it should continue to work. REQUIRED SCRIPTS Fetch is a metascript available in the 1-click installer, though I suggest getting the MetaScriptToolbox (also in the installer) as that gets you all of the metascript toys that help with things like this.
Thank you for you're help.  One more question.  How do I turn on/off the second damage option.  I'm guessing this it the attribute, --dmg2flag|
I figured it out.  Thank you again.
Well I thought I figured it out.  I can't figure out how to turn the Damage2 flag on.
To set the dmg2flag to 'unchecked', you set the value to '0'. --repeating_attack_$0_dmg2flag|0 To set the dmg2flag to 'checked', you set the value to '{{damage=1}} {{dmg2flag=1}}'.  --repeating_attack_$0_dmg2flag|{{damage=1}} {{dmg2flag=1}}
Perfect!  Thank you!