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

[Script] CombatTracker

Testing 1.1.3, doesn't seem to have fixed either issue unfortunately. Here's the relevant API output.

Trying to apply Dazed to a token, entering 5 for the Duration query and -1 for the Direction query:

"handleInput"
"Msg:!ct add dazed 5 -1"
"handleInput"
"Command:ct"
"Action:add"
"Condition:dazed"
"Changes:5"
"Key:undefined"
"Value:undefined"
"Duration:-1"
"Direction:undefined"
"Add Command"
"Condition:dazed"
"Duration:-1"
"Direction:undefined"
"ID:-LjEA-B-S6oaEJT2s_C4"
"Type:graphic"
"Add Condition"
"Token:-LjEA-B-S6oaEJT2s_C4"
"Name:dazed"
"Duration:-1"
"Direction:undefined"
"Remove Condition"
"Name:dazed"
"Combat Conditions"
"Duration:-1"
"Direction:0"
"Send Condition To Chat"
"Combat Conditions"
{"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":-1,"direction":0}


Manually adding Dazed and Confused to the token by adding a item between Condition and Duration, setting duration for both as 5:

"handleInput"
"Msg:!ct add dazed _ 5 -1"
"handleInput"
"Command:ct"
"Action:add"
"Condition:dazed"
"Changes:_"
"Key:undefined"
"Value:undefined"
"Duration:5"
"Direction:-1"
"Add Command"
"Condition:dazed"
"Duration:5"
"Direction:-1"
"ID:-LjEA-B-S6oaEJT2s_C4"
"Type:graphic"
"Add Condition"
"Token:-LjEA-B-S6oaEJT2s_C4"
"Name:dazed"
"Duration:5"
"Direction:-1"
"Remove Condition"
"Name:dazed"
"Combat Conditions"
"Duration:5"
"Direction:-1"
"Send Condition To Chat"
"Combat Conditions"
{"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":5,"direction":-1}
"handleInput"
"Msg:!ct add confused _ 5 -1"
"handleInput"
"Command:ct"
"Action:add"
"Condition:confused"
"Changes:_"
"Key:undefined"
"Value:undefined"
"Duration:5"
"Direction:-1"
"Add Command"
"Condition:confused"
"Duration:5"
"Direction:-1"
"ID:-LjEA-B-S6oaEJT2s_C4"
"Type:graphic"
"Add Condition"
"Token:-LjEA-B-S6oaEJT2s_C4"
"Name:confused"
"Duration:5"
"Direction:-1"
"Remove Condition"
"Name:confused"
"Combat Conditions"
{"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":5,"direction":-1}
"Duration:5"
"Direction:-1"
"Send Condition To Chat"
"Combat Conditions"
{"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":5,"direction":-1}
{"id":"-LjEA-B-S6oaEJT2s_C4","name":"confused","icon":"bolt-shield","duration":5,"direction":-1}


Fifth turn, when both conditions should be removed:

"Turn Order Change"
"ID:-LjEA-B-S6oaEJT2s_C4"
"Announce Condition"
"Token ID:-LjEA-B-S6oaEJT2s_C4"
"Condition:dazed"
"Duration:1"
"Direction:-1"
"Remove Condition"
"Name:dazed"
"Combat Conditions"
{"id":"-LjEA-B-S6oaEJT2s_C4","name":"confused","icon":"bolt-shield","duration":1,"direction":-1}
July 28 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

I've found the issue, just not sure yet how to fix it.  As it's looping through the conditions and matching up to tokens, I'm removing conditions from the same array and forEach is stopping and not processing the last line.  

Thanks for the update! That is odd that forEach isn't processing each line on the same turn..

Also, I noticed in the output I shared, it seems that in the command '!ct add dazed 5 -1', the 5 is being processed as "Changes" instead of Duration. What does Changes do?

July 28 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

When you manipulate an array at the same time you are iterating through it, javascript can get confused.  This is the case, just not sure yet how to fix it.  

July 28 (5 years ago)

Edited July 28 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

New version here, 1.1.4 Beta https://github.com/vicberg/Combattracker

Through TheAaron's help, found a solution to the last condition being skipped.  Last condition is now being removed. 

I also changed logging for the command parsing to be more relevant.  When doing an add condition command, the log on changes won't show and cause possible confusion.  

Testing 1.1.4, all conditions are being removed when they're supposed to! But I still have to add a placeholder between Condition and Duration in the command. Without the placeholder, the Duration is still being ignored, with Direction being parsed as Duration and then nothing being used for Direction.

"Announce Condition"
"Token ID:-LjE9yautiV8a0CWMF-B"
"handleInput"
"Msg:!ct add dazed 5 -1"
"handleInput"
"Command:ct"
"Action:add"
"Condition:dazed"
"Duration:-1"
"Direction:undefined"
"Add Command"
"Condition:dazed"
"Duration:-1"
"Direction:undefined"
"ID:-LjE9yautiV8a0CWMF-B"
"Type:graphic"
"Add Condition"
"Token:-LjE9yautiV8a0CWMF-B"
"Name:dazed"
"Duration:-1"
"Direction:undefined"
"Remove Condition"
"Name:dazed"
"Combat Conditions"
"Duration:-1"
"Direction:0"
"Send Condition To Chat"
"Combat Conditions"
{"id":"-LjE9yautiV8a0CWMF-B","name":"dazed","icon":"aura","duration":-1,"direction":0}
July 28 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

1.1.5 is up now and will take care of that issue

Great work Victor, thank you for getting all of that cleared up! I'm not having any issues with 1.1.5, everything is running smoothly with my testing so far :)
I was testing conditions tonight when I ran into this error:

RangeError: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded at RegExp.exec (<anonymous>) at RegExp.test (native) at ac (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:71) at $b (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:36:239) at mc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:40:370) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:44) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133)
July 29 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

@Professor, is this a consistent error?  

This is the first time I have seen it. Let me see if I can get it to come up again, I'll report back. 

I did not get that same error, I did have this one:

TypeError: Cannot read property 'id' of undefined TypeError: Cannot read property 'id' of undefined at handleGraphicMovement (apiscript.js:8936:33) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:151:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:151:1), <anonymous>:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:1020:14) at updateLocalCache (/home/node/d20-api-server/api.js:1318:18) at /home/node/d20-api-server/api.js:1502:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Rd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)

July 29 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter
These are more intermittent issues.  I'm thinking I may need to reach out to the scriptomancer (The Aaron) to figure these out.  
July 30 (5 years ago)

Is it possible to add an ID to the command so that I could have a macro that makes a character automatically add an exhausted condition to themselves at the end of a special attack? Or does this mod require having the token selected?

July 30 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter


Victor B. said:

These are more intermittent issues.  I'm thinking I may need to reach out to the scriptomancer (The Aaron) to figure these out.  

I'll be off Thursday–Sunday, hit me up on Discord. =D

July 30 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

@The Aaron.  Will do. 

@Stellan, currently only operates on selected tokens.  I could see an integration with Token Mod to do that.  I'm getting my arms around Token Mod as I've started the User Interface.  

July 30 (5 years ago)

Fair enough. I would love to be able to use the add command with an id so I could use macros and character sheet commands to also apply status effects.

Victor, I noticed a tiny bug: the very first time I start combat during a session, it starts on round 2. After that, any time I start new combat, it starts on round 1 as it should.

August 03 (5 years ago)

Edited August 03 (5 years ago)

I've notice a bug that when I start combat, it shows the token I have selected instead of "Round 1" in the chat.  After that, it works correctly.


Also, sometimes there is a rounding error in the initiative roll.  I do have it set to add the dex to the initiative roll for tie breakers.


August 05 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

That's a strange roll.  And yes, I'll find out what's going on with the round 2 start.  

August 05 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter


That long number is IEEE754 rounding errors at work. You can avoid it by formatting the final number to a specific number of decimal places:

pr: (initiativeMod+initiativeRoll).toFixed(2)
August 05 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

Thank you!

Feature request

In the original combat tracker, since conditions weren't preset it would prompt a query for the name of the condition along with it's duration etc. These conditions weren't linked to status icons, either. Could a similar function be added to the new version, if it's generally useful enough? Maybe with a command syntax like

!ct add ?{Name} ?{Duration|1} ?{Direction|0}

I've found myself wishing for this function when things come into play like unique spell effects (especially ability buffs). There's not enough status icons to cover all these possibilities, so it would be really convenient being able to apply a condition/buff that doesn't use an icon and only appears in the turn announcement so it's duration can be tracked.

Or if it's simpler, making status icons an optional feature for conditions? That way more can be added without being limited to the number of status icons.

August 06 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

That's an interesting idea.  I'll consider it.  There wouldn't be a status icon on the token, but the buff (or whatever) would be tracked none the less.  

August 06 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

You could choose one of the colors to represent generics and use its number to tell you how many generics are active on the token. 


Victor B. said:

That's an interesting idea.  I'll consider it.  There wouldn't be a status icon on the token, but the buff (or whatever) would be tracked none the less.  


Yes, this would be especially useful for tracking things in NPCs like an ability or attack buff that lasts so many rounds. I figure the name of such a temporary condition will need to have no spaces in order to not interrupt the syntax if the command. So when queried for the name of the condition I could put "+1atk" or "StrBuff" or whatever.


The Aaron said:

You could choose one of the colors to represent generics and use its number to tell you how many generics are active on the token. 


Only issue here I think is that Combat Tracker uses the numbers on status markers to indicate the duration.


August 06 (5 years ago)

Edited August 06 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

It would still work.  If you set direction to 0, its tracking the number of that condition on the token.  3 bleeding conditions for example which don't go down over time, so direction is set to 0 and it remains at 3 until another character does something, like a heal.  So the same concept could apply for generics.  The number of generics on a token.  

August 07 (5 years ago)

Edited August 07 (5 years ago)

Oh, I see. So could the script have the icon with a static number even if some of the generic buffs have a direction of -1 themselves? Like, purple icon with number 4 to represent 4 buffs, each with it's own duration ticking down each round?

August 07 (5 years ago)

Edited August 07 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

If you are using a single icon to track generic buffs, and then you want differing durations all counting down, what do you display on the icon?  I would assume the number is just showing the number of generic buffs.  At that point, it's possible to then have different duration and different directions for each generic buff and those would display when announcing the player turn.  

That would be ideal. I was concerned that generics with a -1 direction might interfere and cause the icon's number to reduce over time.
August 08 (5 years ago)

Seph if you make your macro using lowcase for the 1st letter it may for better. I just had to change mine to look like this. 

!ct add ?{Condition?|blinded|charmed|deafened|frightened|grappled|incapacitate|inspiration|invisibility|paralyzed|petrified|poisoned|prone|restrained|stunned|unconscious|bloodied|blessed|bardic-inspiration|raging|dodging|ready|surprised|hunter's-mark|faerie-fire|hex|reckless|haste} 0 0

August 08 (5 years ago)
It seem when every you add a condition it opens the Turntracker and unless it is open you can not remove conditions. It there a way to prevent this?
August 08 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

By turntracker, do you mean the turnorder window that shows the order of the players?  That does not happen for me at all.  I'm able to add and remove conditions without combat tracker started or the turnorder window visible or not.  

August 08 (5 years ago)

Selecting the token then adding the icon from the token menu doesn't open it but adding from the Chat menu it seems to or even with the macro posted earlier. I am assuming it is because it is using the CT API command at that point. but could be wrong.

August 08 (5 years ago)

Edited August 08 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

You're macro is opening the turnorder window?  I'm not sure CT is doing that.  CT only opens the turnorder window when your start combat.  What other APIs are you running?  

August 08 (5 years ago)

But it does it from the chat window as well not just from the macro. granted it is the same command that is used. But if I have the CT menu open and add a condition it opens the Turn Order window. If selecting the token and going to the icon and adding it the Turn Order doesn't open.
[If that is clear? :)]

August 08 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

Yes, but I can't replicate it.  Something is forcing your Turn Order Window open.  Any chance you can make a copy of your game and invite me?  Promote me to GM once I join

August 08 (5 years ago)

Sent

I'm still seeing the first person in combat appear before the initiative rolls. In a large combat this means we're scrolling up to find the first check mark. Can all of the turns come after the rolls?



August 09 (5 years ago)

Edited August 09 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

Yes - UGG - this is async at work.  The initiative process is firing before the doturnorderchange and guess what, doturnorderhchange is firing before the rollinitiative is done.  Not as easy to fix

August 09 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

I'd have to put a flag in to check it is set before issuing the announce player.  This might work

August 10 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

Release 1.1.6 Beta is available here https://github.com/vicberg/Combattracker

Fixed

- Rounding Error with decimals (thanks theAaron)

- Fixed display issue where the first player was showing before the initiative rolls


As far as placing conditions with no icons, I tied creating a bunch of conditions using the same icon (brown color).  It worked and I can assign in multiple.  The duration will be the latest assigned, but the other conditions are still there and will count down and display when the characters turn comes up.  

August 12 (5 years ago)

Edited August 12 (5 years ago)


Victor B. said:

As far as placing conditions with no icons, I tied creating a bunch of conditions using the same icon (brown color).  It worked and I can assign in multiple.  The duration will be the latest assigned, but the other conditions are still there and will count down and display when the characters turn comes up.  


Awesome! Is this something you added, or it just happened to already work that way? It's just what I need, and working great. Thanks for letting me know this works!

August 12 (5 years ago)
Ravenknight
KS Backer


Victor B. said:

Release 1.1.6 Beta is available here https://github.com/vicberg/Combattracker

Fixed

- Rounding Error with decimals (thanks theAaron)

- Fixed display issue where the first player was showing before the initiative rolls


As far as placing conditions with no icons, I tied creating a bunch of conditions using the same icon (brown color).  It worked and I can assign in multiple.  The duration will be the latest assigned, but the other conditions are still there and will count down and display when the characters turn comes up.  


Sweet! Looking good Victor.

August 12 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

@Seph, it just happened to work that way.  

The marker image isnt showing up when combat starts


FracturedSolace said:

The marker image isnt showing up when combat starts


Make sure you're testing on the page with the player ribbon, it won't work otherwise.

ah my bad thanks

August 16 (5 years ago)

Edited August 16 (5 years ago)

Getting this error when trying to set a condition:

The condition you are trying to use has not been setup yet

I'm absolutely sure its something I've missed in the config, but can't seem to find it.

Thanks!


August 16 (5 years ago)

Edited August 16 (5 years ago)
Victor B.
Pro
Sheet Author
API Scripter

It means you haven't fully setup the condition.  Open it by clicking on the little cog icon to the far right of the condition in question and you'll see that there's some missing values.  They have to be set before you can use the condition.  You need to set these for ALL conditions you are using.