D&D 4E Line of Sight Checker (for jfrazierjr!)

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Rumble »

This post is a spin off from a thread in General Discussion regarding line of sight checking tools. I developed a line of sight tool that does a quick visual check of LOS according to the rules of 4th Edition D&D. Note that because it's so game-specific, I don't expect this to be in MapTool proper, ever. However, jfrazierjr is building a custom version, and he might like this.

So, basically, it's a new tool on the toolbar, next to the ruler. Click on the button to activate the tool. Then, click on a source token - click near the corner you want to measure LOS from. Then, click the target token, and it will draw four lines to the corners of the target token's space, and a shaded box on the target token to show the true boundaries of the token space (in the event that the token extends outside the grid square, as top-down tokens often do).

Double-click to clear the measurement. If you check LOS to one token, and then select a different token, the visual indicator will move (as expected) to the other token.

This has NO macro code, or any other effect except to draw pretty pictures on the map :D

Here's a screenshot, using top-down tokens.
semifinal-los-tool.png
semifinal-los-tool.png (251.12 KiB) Viewed 1740 times
Here is the patch file for Eclipse:
rumble_lostool_patch_december2.txt
(9.1 KiB) Downloaded 61 times
And here is the telescope icon to use for the buttons (this needs to go in net/rptools/maptool/client/image/tool).
los-tool-blue.png
los-tool-blue.png (1.5 KiB) Viewed 1740 times

User avatar
Natha
Dragon
Posts: 733
Joined: Sat Oct 11, 2008 3:37 am
Location: Limoges/Guéret, France
Contact:

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Natha »

* drool *
ImageImageImageImage

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Rumble »

You know the funniest part? I'm happy with the fact that this works, but I'm most happy that the little telescope icon looks pretty good! :D


One thing that might be cool to add to it is an indication of the distance between source and target - so you click to check LOS, and it also says "5 squares" or whatever. Yes...that is not an original idea. ;)

Edit: like so -
los-with-distance.png
los-with-distance.png (96.41 KiB) Viewed 1716 times

neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by neofax »

Can you change the colors of the lines? Sometimes white does not contrast that well with the background. This will save time as currently I draw lines on the map.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Rumble »

neofax wrote:Can you change the colors of the lines? Sometimes white does not contrast that well with the background. This will save time as currently I draw lines on the map.
Nope, no color changes yet. I realize contrast is an issue - color changing is a pain to add, but another option is do to like the path line: a two-tone line to give it some contrast.

Examples:
Attachments
loscontrast2.png
loscontrast2.png (20.04 KiB) Viewed 1709 times
los-contrast.png
los-contrast.png (121.95 KiB) Viewed 1709 times
Last edited by Rumble on Fri Dec 03, 2010 9:39 am, edited 1 time in total.

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by jfrazierjr »

Would it make more sense in this context to click the TARGET first and then the source? I was thinking for checking LOS, it would be nice to be able to quickly check the same target against multiple points of the source token. ie, move the source vertex.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Rumble »

jfrazierjr wrote:Would it make more sense in this context to click the TARGET first and then the source? I was thinking for checking LOS, it would be nice to be able to quickly check the same target against multiple points of the source token. ie, move the source vertex.
I don't know - it's certainly a good idea. It should be simple enough to reverse the process (he says, boldly).

(edit: actually, it was easy enough to do - swapped a few variables, is all). So, what do people think? Target first, then source? Or the other way around? To me, intuitively, I'd select source -> target. However, jfrazierjr has a good point about quickly checking other corners.

Other possibilities could be keyboard commands to move the origin, or a right-click to clear the thing instead of a double-click (make it easier to clear away and check again?).

User avatar
Hawke
Great Wyrm
Posts: 2261
Joined: Sat Apr 21, 2007 12:12 am
Location: Albuquerque, NM

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Hawke »

I haven't put together your custom build yet, but I wonder:

If ImpersonatedToken = True, Then Source = ImpersonatedToken

Then you click on a target. If no impersonated token, then it works souce->target is how I'd imagine.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Rumble »

Hawke wrote:I haven't put together your custom build yet, but I wonder:

If ImpersonatedToken = True, Then Source = ImpersonatedToken

Then you click on a target. If no impersonated token, then it works souce->target is how I'd imagine.
I'm sorry, I don't follow?

Wait...okay, you mean "if there is an impersonated token, automatically do an LOS check for it?" I'm not sure I like that. There's still the question of which corner to use, for example. I'd also rather this made no assumptions about what you want to have happen - you open the tool, and then it's up to you who is looking at whom.

User avatar
AidyBaby
Dragon
Posts: 383
Joined: Tue Feb 07, 2006 12:55 pm
Contact:

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by AidyBaby »

Rumble wrote:So, what do people think? Target first, then source? Or the other way around?
I would say source then target. Normally you know who's attacking and you're trying to find the best target.

I know you said that as this is so system specific it wouldn't go into the main Maptool build, but I would argue that this is so useful and that we do have quite a lot of D&D specific things already (token sizes, movement metric, auras, etc.) that assuming there are no bugs and it just works, what's the reason NOT to include it? I for one, would use this every session instead of drawing straight lines corner to corner with snap to grid and then undoing said lines.

EDIT - also much prefer the two colour lines.

-- AidyBaby --
D&D qualities are related inversely to those of Poker... and I love both.
http://www.yorkpoker.co.uk

User avatar
plothos
Great Wyrm
Posts: 1890
Joined: Sat Jun 21, 2008 1:07 am

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by plothos »

Two color lines ftw.
I also noted and loved the spyglass icon right off.

As for target or source first i would vote source personally if i had to choose but both would be handy. Would it be possible to have something like the template drawing tool where you get some secondary options to the right of the tool buttons and this would let you toggle between the two?
Drop-In Utilities:
My Spell Manager for D&D3.5 and PFRPG
My Inventory Manager for D&D and PFRPG, but more generally useable than that.
My Message Manager -- My Top-Down D&D Token Images
and my Custom Initiative & Status/Spell-Effect Tracker (work in progress, but functional).

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Rumble »

Okay, so, a couple things:

1. I really prefer source - then - target. However, I also think that being able to quickly check other corners is appropriate! So, I made it so we can have it both ways. The process is:

a. Select the tool.
b. Select the source token (the attacker, in 4E parlance). Click near one of its corners, as usual.
c. Select the target. You'll get the LOS lines and shaded box.
d. Now, if you go back to the source and click near another corner, the LOS lines will change their origin corner.

2. I've noticed an ugly graphics flicker when I use it on my computer here at work (lunch break time!) - when you first select the tool, and try to click on a source token, the whole screen flickers once. It will then work normally, but that first token has an ugly flicker. HOWEVER, this doesn't happen on my home computer - there, there's no flicker or anything. I've discovered that there isn't a flicker if I follow these steps:

1) click the tool to activate it.
2) click on the map anywhere except on a token
3) then click the token

So there's something about component focus and it varies by computer but beyond that, I don't know - it could be a Java version thing, or a graphics driver thing, or...anything. I hope to resolve it programmatically but I'm not sure there is a solution. Any thoughts, anyone? Here's the current code:
rumble_lostool_december3.txt
(11.01 KiB) Downloaded 35 times
plothos wrote:Two color lines ftw.
I also noted and loved the spyglass icon right off.

As for target or source first i would vote source personally if i had to choose but both would be handy. Would it be possible to have something like the template drawing tool where you get some secondary options to the right of the tool buttons and this would let you toggle between the two?
Actually, I was thinking about doing a tool type and then sub-tools, but the subtools would be 4E-style LOS and then just Center-to-Center LOS. I can't think of any other options beyond those (how many types of LOS are there, excluding ones that involve elevation too?). But I'm open to ideas!

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by jfrazierjr »

Rumble wrote:a. Select the tool.
b. Select the source token (the attacker, in 4E parlance). Click near one of its corners, as usual.
c. Select the target. You'll get the LOS lines and shaded box.
d. Now, if you go back to the source and click near another corner, the LOS lines will change their origin corner.
Works for me!!... as long as you don't mind, I will also include this in my custom build along with the other items I am working on(well... once we get b77 out).
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by jfrazierjr »

Quick question(I won't have time to apply and test this until tonight or tomorrow): just glancing at your code, it appears as if the SOURCE token is using the token bounds instead of the footbrint bounds. Is that correct or am I reading this wrong(which is possible... I only did a quick glance through.)?
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: D&D 4E Line of Sight Checker (for jfrazierjr!)

Post by Rumble »

jfrazierjr wrote:Quick question(I won't have time to apply and test this until tonight or tomorrow): just glancing at your code, it appears as if the SOURCE token is using the token bounds instead of the footbrint bounds. Is that correct or am I reading this wrong(which is possible... I only did a quick glance through.)?
Erm. It might be. Lemme check some stuff, I may have just forgotten to do that.

Okay, after testing - both source and target have the lines go from a grid vertex to another grid vertex, not to the token bounding box. That seems to be correct. I'll have to tinker a bit, I may just be getting lucky with the "getNearestVertex()" thing. (edit: and I was. If you make a top down token so that it's way out of its grid square, you can get "invalid" corners because of the nearest vertex thing).

You can go with what I posted, I think. If you wait until tomorrow, I can polish it up - I've been playing around with it and things are in an "in-between" state at the moment. But the patch I posted should work as specified, if you add the icon and the line to ToolbarPanel.

Edit: Argh. One thing - I need to add in something to clear out the last line of sight check, otherwise it remembers it when you add a new map! Easily fixed.
Last edited by Rumble on Fri Dec 03, 2010 1:24 pm, edited 1 time in total.

Post Reply

Return to “MapTool”