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

Complex API Turn Order script request

1391130419

Edited 1391135245
DXWarlock
Sheet Author
API Scripter
I attempted to start it, but with the math to figure it out, and scripting needed, it quickly became apparent it was WAY over my level of javascript noob coding skills. Not even sure if its possible, and if it is, it will take quite a bit of math I think. I was trying to store it in an array after dividing init by attacks per person to get their 'Turn Numbers' and call the next highest number back out of that array as we went along...and thats where I realized I had NO idea how to proceed.. The idea of what it needs to do is simple set the turn order for players/mobs. Its the figuring it out on who goes when that's tricky. Right now I have an out of game excel sheet I made that does it for me, I put in initiate, then attacks, and it figures it out. Does anyone know if this would even be possible to script to reflect on the turn tracker, if not with the turn tracker itself, simply setting aura2 to red and a size for who is up and not using the tracker at all? Let me explain how attack order works. It takes each persons initiative, divides it by number of attacks they have, and spreads them out as even as possible throughout the whole turn starting on their int roll and so on down the row, people taking thier turns until all attacks are done, then reroll init and repeat.. Here is a pic to explain with 6 people setup for combat: The way who goes when is easy, start at the highest red X(whoever got highest initiative) and move down, for example the attack order would be, starting at 21: Dade, Dade, AE, Rip, Dade and Tony(same time), Thumper..etc (for people that all go at the same time, I know that's not possible in the tracker, so any order for them will do(or if using auras just set them all at once), as its all counted when over as simultaneous attacks). We do it this way, to offset when someone has a lot of attacks per round compared to others. So its not round robin, then he goes 3-4 times by himself. it spaces it out so he just attacks more often, with everyone ending the round about the same time. at the end of the round. Of course init divided by attacks doesn't always make a whole number, so it rounds to nearest and put it there. Think its possible? And if so does anyone take donations for coding jobs? :)
1391152522
Alex L.
Pro
Sheet Author
Ok so this should do what you need, you will need to add chat commands your self. its 3 functions: WillTurnOrder.addPlayer takes a token id, the roll and the attack. WillTurnOrder.createOrder() returns a valid turn order string this can be put into the turn order in roll20 without modification. WillTurnOrder.reset() resets the internal stuff. <a href="https://gist.github.com/pigalot/8727749" rel="nofollow">https://gist.github.com/pigalot/8727749</a> This is what the on ready function outputs, it should be the same turn order as you have in the picture: [ { "id": "Dade", "pr": 21, "custom": "" }, { "id": "Dade", "pr": 17, "custom": "" }, { "id": "AE", "pr": 15, "custom": "" }, { "id": "Rip", "pr": 14, "custom": "" }, { "id": "Dade", "pr": 13, "custom": "" }, { "id": "Tony", "pr": 13, "custom": "" }, { "id": "Thumper", "pr": 12, "custom": "" }, { "id": "AE", "pr": 11, "custom": "" }, { "id": "Rip", "pr": 11, "custom": "" }, { "id": "Tony", "pr": 10, "custom": "" }, { "id": "Thumper", "pr": 10, "custom": "" }, { "id": "Dade", "pr": 9, "custom": "" }, { "id": "Dax", "pr": 9, "custom": "" }, { "id": "Rip", "pr": 8, "custom": "" }, { "id": "Thumper", "pr": 8, "custom": "" }, { "id": "AE", "pr": 7, "custom": "" }, { "id": "Dax", "pr": 7, "custom": "" }, { "id": "Tony", "pr": 7, "custom": "" }, { "id": "Thumper", "pr": 6, "custom": "" }, { "id": "Dade", "pr": 5, "custom": "" }, { "id": "Dax", "pr": 5, "custom": "" }, { "id": "Rip", "pr": 5, "custom": "" }, { "id": "Tony", "pr": 4, "custom": "" }, { "id": "Thumper", "pr": 4, "custom": "" }, { "id": "AE", "pr": 3, "custom": "" }, { "id": "Dax", "pr": 3, "custom": "" }, { "id": "Rip", "pr": 2, "custom": "" }, { "id": "Tony", "pr": 1, "custom": "" } ]
1391180683
DXWarlock
Sheet Author
API Scripter
wow..it was that simple? thats a lot simpler than I thought it would be. You sir, I owe a glass of scotch to!