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

[5e OGL] How do I get the attack range of an NPC to display in a macro?

I started with this: %{selected|repeating_npcaction_$0_npc_action} which generated this (by pressing up arrow in chat): @{selected|wtype}&{template:npcaction} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{name=@{selected|npc_name}}} {{rname=Bite}} {{r1=[[1d20+(4+0)]]}} @{selected|rtype}+(4+0)]]}} {{dmg1=[[1d4+2+0]]}} {{dmg1type=piercing}} {{dmg2=[[+0]]}} {{dmg2type=}} {{crit1=[[1d4+0]]}} {{crit2=[[+0]]}} {{description=}} @{selected|charname_output} which displays this: I want to add the attack's range into the {{description=}} area but I can't find the variable it's stored in anywhere.
You can add @{attack_range} to the description field of the attack.
I tried it and got: No attribute was found for @{Gnoll Hunter|attack_range} I also tried it like this: @{selected|attack_range} and got this: No attribute was found for @{selected|attack_range}
Sounds like you're saving the attack's macro code as an Ability (instead of calling %{selected|repeating_npcaction_$0_npc_action}). If that's the case, you'd need to use @{repeating_npcaction_$0_attack_range}.
That worked, thanks. :) I've gotten this far: @{selected|wtype}&{template:npcaction} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{name=@{selected|npc_name}}} {{rname=Bite}} {{r1=[[1d20+(4+0)]]}} @{selected|rtype}+(4+0)]]}} {{dmg1=[[1d4+2+0]]}} {{dmg1type=piercing}} {{dmg2=[[+0]]}} {{dmg2type=}} {{crit1=[[1d4+0]]}} {{crit2=[[+0]]}} {{description=Range: @{repeating_npcaction_$0_attack_range}}} @{selected|charname_output} By taking the code the system generates, but it has hard-coded many of the stats and bonuses, how can I get to use variables so I can use it with any NPC? Also is there a code for centering text?
1496806166

Edited 1496806503
Craig said: By taking the code the system generates, but it has hard-coded many of the stats and bonuses, how can I get to use variables so I can use it with any NPC? My suggestion is to save %{selected|repeating_npcaction_$0_npc_action} as an Ability, which functions identically pressing the first npc action's roll button. Unless you're interested in heavily customing the output of npc actions, this is probably the easiest solution. You could furthermore do something like this %{selected|repeating_npcaction_$0_npc_action} {{description=@{repeating_npcaction_$0_description} Range: @{repeating_npcaction_$0_attack_range} }} which adds the attack range to the description field. Otherwise, the full macro code for an NPC action can be found within the sheet's HTML : @{wtype}&{template:npcaction} @{attack_display_flag} @{damage_flag} {{name=@{npc_name}}} {{rname=@{name}}} {{r1=[[1d20+(@{attack_tohit}+0)]]}} @{rtype}+(@{attack_tohit}+0)]]}} {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}} {{description=@{description}}} @{charname_output} Note that you'll need to add the "repeating_npc_action_ID_" to some of the Attribute calls (namely those within the {{Roll Template property fields}}, except @{npc_name}).
Your first example worked but when I tried the second code I got a screen full of errors, I tried following the link and copying the code from there (excluding the " " around it) and got errors again, what am I missing?
1496808002

Edited 1496808010
Craig said: what am I missing? You'll need to add the "repeating_npc_action_ID_" to some of the Attribute calls (namely those within the {{Roll Template property fields}}, except @{npc_name}). e.g. replace @{attack_tohit} with @{repeating_npc_action_$0_attack_tohit}
1496810162

Edited 1496811340
OK so I changed a bunch of the variables: @{wtype}&{template:npcaction} @{selected|repeating_npc_action_$0_attack_display_flag} @{selected|repeating_npc_action_$0_damage_flag} {{name=@{npc_name}}} {{rname=@{name}}} {{r1=[[1d20+(@{selected|repeating_npc_action_$0_attack_tohit}+0)]]}} @{selected|repeating_npc_action_$0_attack_type_display}+(@{selected|repeating_npc_action_$0_attack_tohit}+0)]]}} {{dmg1=[[@{selected|repeating_npc_action_$0_attack_damage}+0]]}} {{dmg1type=@{selected|repeating_npc_action_$0_attack_damage_type}}} {{dmg2=[[@{selected|repeating_npc_action_$0_attack_damage2}+0]]}} {{dmg2type=@{selected|repeating_npc_action_$0_attack_damage_type2}}} {{crit1=[[@{selected|repeating_npc_action_$0_attack_crit}+0]]}} {{crit2=[[@{selected|repeating_npcaction_$0_attack_crit2}+0]]}} {{description=@{selected|repeating_npc_action_$0_description}}} @{charname_output} I tried 2 different formats: @{selected|repeating_npc_action_$0_description} and @{repeating_npc_action_$0_description} I got the same errors both times: No attribute was found for @{selected|repeating_npc_action_$0_attack_display_flag} No attribute was found for @{selected|repeating_npc_action_$0_damage_flag} No attribute was found for @{Gnoll Hunter|name} No attribute was found for @{selected|repeating_npc_action_$0_attack_tohit} No attribute was found for @{selected|repeating_npc_action_$0_attack_type_display} No attribute was found for @{selected|repeating_npc_action_$0_attack_tohit} No attribute was found for @{selected|repeating_npc_action_$0_attack_damage} No attribute was found for @{selected|repeating_npc_action_$0_attack_damage_type} No attribute was found for @{selected|repeating_npc_action_$0_attack_damage2} No attribute was found for @{selected|repeating_npc_action_$0_attack_damage_type2} No attribute was found for @{selected|repeating_npc_action_$0_attack_crit} No attribute was found for @{selected|repeating_npc_action_$0_description} SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "s" found.
Ah, it's repeating_npcaction, not repeating_npc_action.
Now I'm off to the races! Thanks so much for your help! :)
D'oh! I was so close! It should be working now but I'm getting an error about a missing or extra bracket, I've combed over it again and again and I can't see where I messed up. @{wtype}&{template:npcaction} @{selected|repeating_npcaction_$0_attack_display_flag} @{selected|repeating_npcaction_$0_damage_flag} {{name=@{selected|npc_name} (+@{selected|repeating_npcaction_$0_attack_tohit} @{selected|repeating_npcaction_$0_attack_type}) Range: @{selected|repeating_npcaction_$0_attack_range}}} {{rname=@{selected|repeating_npcaction_$0_name_display}}} {{r1=[[1d20+@{selected|repeating_npcaction_$0_attack_tohit}]]}} {{always=1}} {{r2=[[1d20+@{selected|repeating_npcaction_$0_attack_tohit}]]}} {{dmg1=[[@{selected|repeating_npcaction_$0_attack_damage}]]}} {{dmg1type=@{selected|repeating_npcaction_$0_attack_damagetype}}} {{crit1=[[@{selected|repeating_npcaction_$0_attack_crit}]]}} {{dmg2=[[@{selected|repeating_npcaction_$0_attack_damage2}]]}} {{dmg2type=@{selected|repeating_npcaction_$0_attack_damagetype2}}} {{crit2=[[@{selected|repeating_npcaction_$0_attack_crit2}]]}} {{description=@{selected|repeating_npcaction_$0_description}}} @{charname_output} The error is: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but end of input found. The error happened when I put in the [[inline rolls]], everything running and displaying fine before that.
I figured it out, I noticed there were extra +0s added on all the inline rolls in the code, couldn't figure out why, threw them in figuring what the hell and it fixed it, I guess they prevent inline rolls from failing due to empty variables. Works perfectly now, thanks again! :)
You're very welcome! Happy rolling!