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

using the api to add actions to an npc sheet (5e OGL)

I'm trying to make enemies that have randomized move sets as part of a dungeon theme, what I want to do is get one of the players to roll a D100, then from that I would have a list of actions, I could click one, tell it what npc sheet to go to and it would then go to that sheet, create a new action and fill in the details for me just so every time one of these things spawns I don't have to sit there and manually fill it all in.  If you provide a script could you give a brief description of what things I would need to edit and what they correlate to I realize this is probably a difficult task or perhaps impossible but I had to ask :) thankyou for your time.
1563158078
GiGs
Pro
Sheet Author
API Scripter
Its possible, and the individual steps are not really that hard, but putting them together in a coherent whole is hard without a lot more guidance. The three big questions: What is the list of actions? We'll need to know the list of actions, and ability text for them. (Give us a few examples, if you dont have the full list yet.) How are you choosing the NPCs? From a list of npcs in your journal? All npcs linked to tokens on the current map? all characters in a specific folder? How does the player-rolled d100 work? Given answers to those questions, we can put it together.
1563158624
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
When you say "actions" do you mean the abilities (macros that go on character sheets in the attributes and abilities tab)? Or do you mean things like add a weapon, or an attack? Either one is possible, but are likely difficult to accomplish.
so, you know how in the OGL you have certain boxes to fill in like the attack checkbox, ranged or melee, reach, to hit etc... there are some actions (like say this enemy has a longbow) which will use most of those boxes so to put it into full practice name: longbow (filled in) attack (checked) type: ranged (selected from the dropdown menu) range/reach: 60/100ft (filled in) on hit: 1d10+[dex mod] (filled in, also I'm not sure how to reference the dex mod of an npc sheet via the in game code) (damage type box): Piercing on hit 2: both boxes left blank description: blank on the other hand some of the actions are simply abilities that can just be filled out in the description box (like a "roll a con save vs this ability or you're stunned until the start of it's next turn" action) the npc chosen will be from a list in the journal (if possible) I already have the stat blocks churned out, but its the actions themselves which will need to be chosen the D100 roll is just a standard roll, I don't need it to be part of the code it's just the player rolls a D100 and depending on their roll I click the buttons and the code populated the selected NPC sheet with actions based on the roll
1563159256

Edited 1563159290
keithcurtis said: When you say "actions" do you mean the abilities (macros that go on character sheets in the attributes and abilities tab)? Or do you mean things like add a weapon, or an attack? Either one is possible, but are likely difficult to accomplish. when you look at the 5e ogl NPC sheet it's separated into the main stat block, their abilities and then a section labeled "Actions" where you can click a plus button and fill in the boxes as I explained in my other reply post, that's what I'm referring to not the attributes and abilities tab macros. Sorry if this makes things more complicated but I thank you both for taking the time to reply :)
1563159618
GiGs
Pro
Sheet Author
API Scripter
Ah, sorry, thought you meant the Abilities tab. I'm not familiar with that sheet, but what you're asking can most likely be achieved using the existing script, chatsetattr. 
I have no idea how the api stuff works here ^_^; it's all a bit new to me, is there a place where I could read how it works and how it maybe could be applied here to achieve this task?
1563160146
GiGs
Pro
Sheet Author
API Scripter
chatsetattr has extensive help, but in essence, it lets you add or modify existing attributes on a character sheet. Everything on the character sheet that you can change is an attribute, and so can be adjusted through this script. Instructions are here:&nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/tree/master/ChatSetAttr" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/tree/master/ChatSetAttr</a> You'd install it, then set up macros or another script to let you select the weapon/action, and then insert the attributes on the sheet. I can't give much more help because it requires specialised knowledge of the sheet which i don't have.
1563166280

Edited 1563166974
GM Michael
API Scripter
The API is documented on the wiki . ChatSetAttr is about the closest we have to a terminal at the moment.&nbsp; Having said that, because it's slower than a dedicated script in most circumstances, I don't actually use it for that much, instead opting to go write a script to do whatever it is that I wanted, and keep my use of ChatSetAttr limited to simple things like a macro button to let me change the tint of a token.&nbsp; If you go this route, make sure to use multiple attributes per command to avoid getting stuck in the evils of query nesting . If you do want to pursue a dedicated script, I'd recommend taking a look at my Mass Combat script for 5e OGL for inspiration.&nbsp; It can convert individual NPC stat blocks into formation stat blocks, which includes editing many fields (such as attacks) and adding a new trait.&nbsp; Full details on the github .
1563168313
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
ChatSetAttr is likely a little hobbled at the moment with the current bug that sheetworkers are not being triggered by the API . Nevertheless, the idea is sound, though it would likely take a huge amount of programming. It might be better to put 100 Abilities on a sheet, and activate them with a chat menu or a drop down. In any case, swapping out 100 different actions will be tough regardless of the method.
1563189173

Edited 1563191726
GM Michael
API Scripter
keithcurtis said: ChatSetAttr is likely a little hobbled at the moment with the current bug that sheetworkers are not being triggered by the API . ... I believe Mass Combat is in the same boat, unfortunately.
so, my next question would be, how would you set up a list for the script to draw on? could you just put them in a handout? would you create a macro for each individual one? and how would they apply to the sheet? sorry if I'm asking stupid questions but this is really new to me.. I've got no experience with this.
1563197824

Edited 1563197847
GM Michael
API Scripter
You could make a drop-down query in a macro, but with how many options you have, I'm not sure if Roll20 even supports that many. Yes, you can create links in a handout.&nbsp; This is how my SpellMaster script works, so you could take a look at that for reference if you'd like, but it's pretty straightforward and you can do this yourself just by hand-editing the handout. [Link Text](!myScript -param1 -param2) You could also have a chat UI, but that would fill up the chat pretty quickly and be a lot of scrolling, so a handout is probably best.
does your spellmaster script deal with NPC actions too or just player character spells?
1563225337

Edited 1563225618
GM Michael
API Scripter
It's spells, though I suppose you could run any attack through it and treat them as cantrips.&nbsp; PC or NPC shouldn't matter.&nbsp; I suppose that probably does what you're asking for lol.
kinda... I was hoping there was a way to run them as npc actions but I guess that's wishful thinking... and I would need to treat them as first level innate spells since some of them would have limited numbers of uses