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] Movement Tracker and Aura Highlighter and HP change Announcement

Special thanks to Konrad J. &nbsp; Movement Tracker The movement tracker requires a character to have an attribute named "Speed". It then uses the current value to keep track of how much movement is left, and displays an green aura where the character can reach (approximately). As you move, it leaves pins in previous stop points, so you can see your path and determine attacks of opportunity and others. Since the system does not display realtime movement of players, this is a great way for DMs to track where characters move.&nbsp; The DM will need to add 15 tokens named: XPin1, XPin2, XPin3, XPin4, ... etc. These tokens will mark the movements of the character. You can use any token to your liking. If a player decides they are not happy with their movement, they can type !MoveDoOver, and it resets them entirely.&nbsp; If they want to go back one step, they can type !MoveLast. This will move them back to their previous position. There are several settings in the beginning of the script which you can use to set to your liking: TOTALPINS is the number of pins you are using. If you put a number here higher than you have, it is not a problem. However, if you have more pins than this number, it will ignore those higher. SQUARE_AURA if you want square auras instead of circles, set this to true. Aura1_Color is the further aura if the characters have the option to double move. If you set this to 'transparent', it will not appear. This is in Hex colors Aura2_Color is the color of the movement aura. This is in Hex colors. GMName is the display name of the GM. Set it to your display name. This way, you will be able to override movements in play. DISPLAY_MESSAGES set this to true if you want the system to announce errors or problems. It will post if people try to move when it is not their turn, when they try to force a !MoveDoOver or !MoveLast when it is not their character moving. It will also stop posting if the character tries to overmove past their speed. Here is a video sample of a beta of Movement Tracker:&nbsp; <a href="http://www.youtube.com/watch?v=s0Mx-KCbnqI&amp;feature=youtube_gdata" rel="nofollow">http://www.youtube.com/watch?v=s0Mx-KCbnqI&amp;feature=youtube_gdata</a> Here is the link to the Movement Tracker:&nbsp; <a href="https://gist.github.com/DarokinB/5715738#file-gistfile1-txt" rel="nofollow">https://gist.github.com/DarokinB/5715738#file-gistfile1-txt</a> Hit Point Change Announcer This code requires the characters to have an attribute named "Hp". It then tracks and announces any changes to Hp. When monsters are placed on the board, they are not linked to an attribute, and so they announce changes to Bar1's values (assuming that is used for hitpoints. Here is the link to the HP change announcer:&nbsp; <a href="https://gist.github.com/DarokinB/5708569" rel="nofollow">https://gist.github.com/DarokinB/5708569</a> Please review and feel free to criticize.&nbsp;
Josh I really like the 'waypoints'! &nbsp;Could the 'undo' option be changed to undo to a given point? This could be useful for traps/effects triggered by movement.&nbsp; A version that also worked with hex grids would also be cool (with a circular aura?)
These look to be very helpful...esp. in helping the GM make sure no fudging going on in these areas. I couldn't see the small video much when watching full screen (low quality) so I'll have to wait on additional comments until I can run them in a test campaign I have. &nbsp;Thanks for the contribution!
I used a square aura because I work in chrome and right now I am getting the error that circle aura's dont appear. I am going to add a few variables in the beginning of the script so you can choose to have it be circular or not. Sorry about the video quality. I work off a laptop, and generating high quality video is not it's thing, I just wanted to toss something together to give a sample of how it works. I haven't spent a lot of time playing with Hex, I will toy around with it and see how it works, but I am sure I can.
I have updated the Movement Tracker. Now, it places the aura on the pins instead of the character. This means it does not lock up either of the players auras for this feature. It also shows the max the character can move while they move the token which is nice. I also added a command "!MoveLast", this allows you to move back to the last point you had.&nbsp;
Now, I need to add security. As it sits right now, if any player types either of the text commands (!MoveDoOver or !MoveLast) it will move the character back. I want to limit this to only the player that controls the character. I know how to test who controls the character, but how do I get the player who moved the token or typed the command?&nbsp;
Right now you can't get who moved a token, but you can get who entered a command with var Player = msg.who or something like that.
You should be able to get a list of who's allowed to control the token from the Graphic.controlledby or so. I've not tried that yet, but seems that returns the user ID so you have to convert that into a name first Last I heard the GM does not show up in this list (unless he specifically added himself), so you have to figure out who the GM is somewhere else. Also circular auras are also better for game systems where diagonals are treated as 1.5 squares like in Pathfinder, where a round aura is a closer approximation.
Unfortunately, the graphic.controlledby was blank, because it inherits it from the character. I had to pull the character.controlledby and then compare. I was able to get it to work however, though I need a player to log in and test it (as a DM I can emulate everyone). To do this, I compare the displayname to the players, and pull a playerID. I then compare the player id to the controlledby for the character. If it is a match, it goes. If not, it yells at the player ("Josh, you do not control this player"). As a catch all, If the display name is the same as the graphic.name, it allows it. The Gist is updated. EDIT: Though the system grants the GM the power to move all tokens, I assign the GM as a controlling player. This allows me to have control of them. If you do not do this in your game, the system will yell at you when you try to move a token controlled by a player.
And finally, I have added Hex support! Blamo! Please note, I will be editing this down to simplify it using functions and what not. I hate messy code and thats exactly what this is!
this is a well written script, messy or not. Might i suggest adding in a few lines so the DM can enable/disable the script via chat commands? or, actually, detecting if the turn tracker is up... that would be a simple one to add in, and allow 'normal' operations when it is closed. if i could program at all i would add it in, but I'm afraid that I have never worked with java. and currently work with 4 kids. barely have enough time to run my games in my spare time, which saddens me. currently trying to smush lines of code in that i dont really understand o make little changes to everything i blatantly rip to make my game seem cool to my players
one more thing...... the hp tracker... i keep getting messages every turn that this pc or that pc has healed for what appeared to be their movement....
What values to use for the Speed Attributes? &nbsp;Squares or "Feet"?
1370569053
Konrad J.
Pro
API Scripter
Josh said: Now, I need to add security. As it sits right now, if any player types either of the text commands (!MoveDoOver or !MoveLast) it will move the character back. I want to limit this to only the player that controls the character. I know how to test who controls the character, but how do I get the player who moved the token or typed the command?&nbsp; For most of my commands that GMs might not want players to do I put a conditional and check they are the GM or not. &nbsp;Also can set this off or on. &nbsp;I made a function to check for GM. &nbsp;Currently there is no way to know who the GM is for sure. &nbsp;My first idea was to look for the work GM in the display name since ROll20 adds this, but players could simply add it to their name? &nbsp;SO now I simply add a global variable. &nbsp;The GM puts his display name into the global variable when he sets the script up. &nbsp;Now we have a way to know who the GM is. &nbsp;You could even then setup CoGMs this way.
1370569142
Konrad J.
Pro
API Scripter
Michael H. said: this is a well written script, messy or not. Might i suggest adding in a few lines so the DM can enable/disable the script via chat commands? or, actually, detecting if the turn tracker is up... that would be a simple one to add in, and allow 'normal' operations when it is closed. if i could program at all i would add it in, but I'm afraid that I have never worked with java. and currently work with 4 kids. barely have enough time to run my games in my spare time, which saddens me. currently trying to smush lines of code in that i dont really understand o make little changes to everything i blatantly rip to make my game seem cool to my players I agree, its a good idea to be able to turn on/off tracking, etc. &nbsp;I've got a bunch of options n my version of the script. &nbsp;I just need to document it so I can let it out in the wild! &nbsp;No time for a couple weeks though.
Hi Konrad. I currently use your movement tracker (incomplete as it is) in my campaign. I must admit to putting in one change though - switched to feet and added math.floor to round down to the nearest five feet segment. i'll post that in your topic actually, for anyone else that wants to use it. Also, and no offense Josh, using your system I have managed to get an extra five feet out of my speed by bugging the diagonal movements. not every time, but it is possible. i mostly don't care, to be honest, my players like breaking the rules so I don't mind leaving in something that makes them feel like they beat the system. Just pointing that out, as it was Konrad's early version of his movement tracker that helped me figure it out.
1370582945
Alex L.
Pro
Sheet Author
Nice script but i would suggest you namespace your globals. See this if you need to know how to namespace.
Michael H. said: this is a well written script, messy or not. Might i suggest adding in a few lines so the DM can enable/disable the script via chat commands? or, actually, detecting if the turn tracker is up... that would be a simple one to add in, and allow 'normal' operations when it is closed. if i could program at all i would add it in, but I'm afraid that I have never worked with java. and currently work with 4 kids. barely have enough time to run my games in my spare time, which saddens me. currently trying to smush lines of code in that i dont really understand o make little changes to everything i blatantly rip to make my game seem cool to my players I appreciate this. I like the disable/enable idea, I will be adding it tonight. The system checks not only if the turn order is up, but if it is also populated, and is disabled when it is not.&nbsp; Michael, if you could get me an example when a character gets an extra move, i would appreciate it. That way I could fix it so it does not happen further. Actually, I think I may have discovered it and I will work on it more. Alex, I actually worked on that tonight. I broke it down into many functions to make it easier, it was what I meant by cleaning up my code ;) Thanks!
Ok, I added a toggle. If the user types !ToggleMovement it will enable and disable the system. I also looked at the algorith for movement and realized my problem, it was rounding down every diagonal each time for short movements. This meant you could get more diagonals, potentially getting the calculations wrong. I have since fixed it.&nbsp;
looks good mate. I knew it was something wrong with the diagonal movement and the way it was working out the 1 diag=5ft, 2diag=15, but was on my way out the door for work. should have been more specific in the original post. Was going to look at it tonight.... now I get to play with your new code and see if i can break it again... and thanks for the toggle. I guess I'm just lazy, but I don't think I've ever depopulated my init tracker, I leave the pc's on it permanently so I never realized the on off trigger.
been playing, just thought I'd point out that the script breaks when you clear the init tracker. at least, i used the clear option, and the movement tracker stays onscreen with the aura up.&nbsp; also, I find after tinkering that using both auras on the movement tracker works really well...&nbsp;&nbsp; for example, putting the first aura up as = to speed to match the movement allowed with a move action, and then the second aura as twice speed for possible movement over the entire round (I currently use the blue icon for speed, and basically double it to give full possible range of movement in any given round. just thought that a second aura would help players see the cutoff point. not sure about the aura opacity though, don't want it to be too dark, not sure what you could do with that.
error message that comes up after clearing the init tracker: TypeError: Cannot call method 'get' of undefined&nbsp; at evalmachine.&lt;anonymous&gt;:53:32&nbsp; at eval (
1370613132
Alex L.
Pro
Sheet Author
Michael H. said: error message that comes up after clearing the init tracker: TypeError: Cannot call method 'get' of undefined&nbsp; at evalmachine.&lt;anonymous&gt;:53:32&nbsp; at eval ( This is what happens when you dont check to make sure objects are valid before using them :P
Hmmm... I will have to take a look at this. I don't believe there is a function for when something is removed from initiative. Let me look into it. I have an event handler for when the initiative is empty, but apparently after something is deleted that does not fire as true.&nbsp;
Michael, you just pointed out a problem to me. Right now the system would not let someone make a double move. I will have to fix this. I fixed the problem with the pin remaining after you clear the initiative. I will add the new code once I figure out double moves. I think you might be onto something Michael.
Ok, I fixed it! Actually it wasn't that bad thanks to my cleaning of my code. I also added two constants in the beginning that will allow you to set the colors of the aura's to your taste. I would recommend going to 15 pins for double moves (for zig zag movements and the like).
Alex, after reading through namespacing, I think you are right. There is a risk my globals could interfere with someone else's. I will work on it tonight or tomorrow. Thanks! EDIT: Done! This will protect it from being used with other scripts.
Thank you. And might I add: You're work here is appreciated. In fact, its downright amazing that you're putting this much effort and care into your code or for that matter listening to someone that has no idea how to code for himself, though reading through everyone's published codes is helping me learn some, I must admit. ok, gonna go test again.&nbsp; ps, the only reason I mentioned the double move was because the monk in my party has speed 50 - thats a fair distance to have to eyeball half&nbsp; move, even i was having to start counting again on some of them otherwise I was just putting in speed as double and it was working fine. I also had more than five pins on&nbsp; your last script anyways - mostly for that damned monk
ok, turns out my last post was erroneous. I messed up naming the pins. thought it was a movement issue. just ran out correctly named pins. so far so good, working exactly as I hoped it would. Again, you're work here is amazing.
I also updated the HP change announcer, there was a problem that it would announce for any stat changing. This has been fixed.
Josh, Great job with the API. &nbsp;Truly a really cool bit of work you've done here. &nbsp;I did find an issue that I'm not quite sure how to correct myself. &nbsp;I added a custom object into the turn tracker that isn't associated with any token on the board, it's just for keeping track of the round. &nbsp;That seems to break the script when it comes up in the turn tracker as it isn't tied to any token at all. &nbsp;It causes the script to bomb with the following error: TypeError: Cannot call method 'get' of undefined at evalmachine.&lt;anonymous&gt;:35:48 at eval (
Can you put all the code of the line? Also, be aware that it's case sensative, so if you name your token RoundCount and in the code you put roundcount, it will show it as undefined.
1370803303
Konrad J.
Pro
API Scripter
I like to change all the chat window commands to all lowercase and do any finds with the caseinsensitive option. &nbsp;This way the user can type the command anyway they want and the token can be named any way they want. &nbsp;But the disadvantage is then tokens with the same name, but different caps will break it I guess. &nbsp;Trade off, but I don't thikn people will name tokens the same, but different caps as much as they will type things wrong in the command window. var objMoveTrackToken = findObjs({_type: "graphic", _pageid: Campaign().get("playerpageid"), name: tokenName}, { caseInsensitive: true })[0]; on("chat:message", function(msg) { &nbsp; &nbsp; // returns the chat window command entered, all in lowercase. &nbsp; &nbsp; var chatCommand = msg.content; &nbsp; &nbsp; chatCommand = chatCommand.toLowerCase(); //make all characters lowercase &nbsp; &nbsp; var argv = chatCommand.split(' '); &nbsp; &nbsp; if (msg.type != 'api') { &nbsp; &nbsp; &nbsp; &nbsp; return; &nbsp; &nbsp; } &nbsp; &nbsp; return processScriptTabs(argv, msg.who); });
ok, I have basically implemented your code into my game now. The players are enjoying the faster flow of combat. The only thing I am having trouble with is moving icons during combat. specifically to reposition them without using speed (examples include picking up and moving a character going up some stairs, to move them to the next floor up, and falling down a slope to hit the ground. Some can be done with !ToggleMovement I'm sure, though I am still unclear on how to implement that one successfully... (far as I can tell it only updates on turn order changing, and sometimes it necessary to move a token during its current turn - don't know exactly what can be done there....) The other thing I am working on (and bear in mind I can't code for pancakes) is a teleporting script that won't break this (or hopefully any other) movement tracking scripts. Basically link two icons placed by the DM ( Planning on using transparent layer icons to mark location, easy enough to put together ) and have a any icon that moves into that square repositioned to the second Icon linked by name ( probably by using a name like teleport1A and teleport1B) &nbsp;and having the code search for any icons occupying the same square and moving them to the other linked icon. I would have to set subroutines for determining if it was a one way teleport or workable both ways ( All from the teleport icon so it can be done 'in game' to simulate portals closing, stairs collapsing or anything else that the DM wants to shut the movement down for ). To work around your plug in i think the easiest solution would be to calculate the distance traveled and simply add that to current speed before the movement of the teleport. that way it would hopefully work with anyones code that uses the same conventions for tracking distance moved. Now, not being a coder (at least, not since the days of basic) I am unsure exactly how to code all this. was wondering if anyone else here was working on something similar? Its going to take me weeks, if not longer, to code this as I am literally learning as I go, and if someone else was working on something similar I would love to have a look at their code so I could get an skeleton of my framework. or help them test theirs if theirs is close enough to what I am looking for
Hi Michael! Thank you for your post and thanks for using my script :). I think this is an excellent idea. I am going to give the auto mover a shot today and see how it goes. As for moving characters as you see fit, I created a macro for toggling and when I need to move someone, I toggle, move them, and toggle again. The only time there is a problem is when someone needs to move in the middle of their turn. I think I will add an override that a DM's movement does not count against the script. It's a little complicated in that scenario however. Instead, I may make it so that if the DM is moving it, it ignores maximums. I will play around with it and let you know.
Adding a line or two to allow the DM of the game to move characters would be a good work around for now, just wondering it would be easier to add a line that checks if the person moving the character is the DM, and if it returns as true, simply adds the distance moved to the character current speed before the move, which would effectively give the DM free movement on all tokens for the low price of... two...? lines of code, as adding the amount moved to current.speed before recalculating the current speed would zero out the move. shouldn't break anything.....
Hi Michael, the problem I am facing is that it is not clear (I have not been able to find it) who is actually moving the token. If the GM and player both have rights, there is no way to test who moved it to count that movement as 'extra'. Instead, I created a toggle that will allow it to move past the maximum, which only the GM can toggle. I have added it to the script. Essentially, when you need to move extra, you type (I created a macro and quick button for it) !Override_Maximum. When the turn is done, click it again and it returns to normal.
Michael, I created a teleporting script, I created a new topic. Thanks for the suggestion!
Ah. Sounds good. I was unaware you had not yet determined a method for pulling the users name from the movement. No that you have mentioned it though, I understand the problem. Am I to understand that the !Override_Maximum command is essentially a 'pause' on the script in general?&nbsp;
Yes, you can move a token past it's maximum speed as far as you need.
Josh said: Can you put all the code of the line? Also, be aware that it's case sensative, so if you name your token RoundCount and in the code you put roundcount, it will show it as undefined. Josh, that was the error in it's entirety that failed.&nbsp; Again, the object in the turn tracker is not an actual token on the board.&nbsp; It is one of the ones that you can add with the "Add Custom Item" option when you click on the gear icon to access the turn order settings.&nbsp; Whenever I add any of these for various purposes such as keeping track of the round, or how long a spell effect should continue, etc. it breaks the script and it bombs with the aforementioned error, which again is: TypeError: Cannot call method 'get' of undefined at evalmachine.&lt;anonymous&gt;:35:48 at eval ( I figure it must be that it's trying to perform a get on the token properties of that custom item, but there is no token to pull attributes from.&nbsp; I'm guessing there needs to be a check for these custom items to ignore them, but I'm not sure how to go about doing that myself unfortunately at this point.
Oh haha I wasn't aware that option existed! I have fixed it, it works fine now with custom items in the initiative tracker.
Thanks Josh!&nbsp; That works perfectly!&nbsp; Between this script and the teleporting one, I think I pretty much have everything I can think of that I'd need to run an absolutely awesome campaign online.&nbsp; Thanks again for your hard work on this one.
Updated with several bug fixes and better control on double moves! Special thanks to Quatar for his help!
only problem is now it doesnt factor in the diagonal moves correctly &nbsp; it doesnt work now with pathfinder/3.5 style movement as it did - I can move four squares in either diagonal with 20 ft of movement; should only be three squares diagonally
Thats based on the map's settings which you are on. If you have the map set to squares 4e style, second diagonals do not count double. The script just checks the current maps settings and calculates accordingly.
ahhhhhh. I find myself grinning foolishly&nbsp;
Josh said: Updated with several bug fixes and better control on double moves! Special thanks to Quatar for his help! You're very welcome and thank you for posting this version. And thank you for having done all the hard work on this in the first place :) There's a new Setting in the script now DEFAULT_DOUBLE_MOVE. It's set to false by default, and thereby activates the new functionality. But if you liked the old one, just set it to true and the script will behave just like before. Otherwise a token is stopped from moving past single move and has to manually type !DoubleMove to be able to do that. This will send a message to the GM as whisper or announce it in chat, depending on how the DISPLAY_MESSAGE setting is. I've also made a couple of tracker tokens for myself to use as Pins for this, and I figured I can share those too: <a href="http://www.filedropper.com/movementtrackertokens" rel="nofollow">http://www.filedropper.com/movementtrackertokens</a> They look like this: numbered from 1 to 20. Setting them up the first time is a bit of a pain, because you have to upload them and then name them XPin1 to XPin20, but for me I found it makes tracking the actual path a token takes easier. They're also 6x6 squares huge, but the script resizes them to normal size automatically the first time it uses them, so don't worry about that. I tried making them smaller but that made them look ugly especially when you zoom in. Also is it normal that the preview up there still shows an old version of the script? When I click the link I get the new one, but not in the preview on the forum. Does that just take some time?
Yea, unfortunately, the preview system uses the first version of the script when posted. I have found a couple work arounds but its not 100% successful.&nbsp;
Have to ask is it possible to add in &nbsp;step that allows for only showing the currently available movement? As in only one aura at a time? Playrrs pointed out that with two auras up it made the map beneath a little hard to see... so have movement up then reset the counter to allow for the second movement aura to show up?&nbsp;