Unit Grouping (with Rotation): SOLVED! (Updated 12/5/2010)

Show off your RPG maps, campaigns, and tokens. Share your gaming experiences and stories under General Discussion and save this forum for things you've created that may help others run their own games. Use the subforums when appropriate.

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
KaylaKaze
Cave Troll
Posts: 57
Joined: Mon Jun 18, 2007 1:08 pm
Contact:

Unit Grouping (with Rotation): SOLVED! (Updated 12/5/2010)

Post by KaylaKaze »

Grouping v1.12
by Kaylakaze
--------------------------
I've completed a drop-in set of 1 token and a campaign macro file to import. When you first add the Control Unit to a map, make sure you activate the "onCampaignLoad" macro on it. To put it simply, select the units you want to make a group and then hit the "Create Group" campaign macro. The group will be created with the formatin facing left ie: if you're in a rentangular formation, the first rank will be to the left, and the final rank will be the one on the right. Once a group is made, any unit can be used to move and rotate the group. Simply move the token where you want it to be and rotate it how you want, then hit the "Fall In" campaign macro. Make sure snap to grid is turned off or they won't form up properly (probably). Units with state "Dead" will be left behind, but will still be part of the group. They won't move with the group so you can move them wherever you wish. If they become no longer dead, they will rejoin the group in their previous location. To remove units from a group, select them and hit the "Remove Unit From Group" campaign macro. This will remove the unit from the formation, however a hole will be left where it was (no real way to fix that). Groups persist on campaign reload. The "Disband Group" macro will ungroup all the units in a selected unit's group.

Variables required for use:
The Control Unit uses Strength and Constitution to store sine and cosine tables.
Grouped units use Elevation to store their unit serial number and Description to store the list of group members.

Using serial numbers is a lot slower than using token IDs, but token IDs don't persist. The serial number is made up of 7 1d1000 rolls, so the chances of having a duplicate are extremely low. But, if it happens, just remove one unit from it's group and regroup them. This will create a new serial number.

Any formation positioning issues are likely to be caused by snap to grid, either with it left on after grouping, or tokens not reporting their proper position due to it during group creation.

We did have an issue during testing where certain units weren't reporting their facing to MapTool. We have no idea why. This was a MT issue (as the setFacing and getFacing commands just plain didn't work) and not an issue with the grouping but caused grouping to not work completely correctly. If it comes up that way for you, try using a different unit in the group to move the group. Other than that, I don't know what to tell you.

This is GREAT for playing Warhammer Fantasy. If you do play WH, invite me to watch :-)

EDIT: Oh, I forgot to mention. If you add a "Fall In" speech variable to a unit, when that unit is used to make the group move, there's a 1:4 chance that it'll "say" that speech text. Obviously, you can change this chance pretty easily if you want it to be more or less frequent.


Changelog:
v1.12: - added error checking so that if a token in a group no longer exists (for whatever reason), the group commands still work.
v1.11: - fixed bug from having left defunct code in the token's macro
v1.1: - No more brackets, just select units for creating group
- Added Disband Group functionality
- Added Readme File
v1.0: - Initial release
Attachments
Grouping v1.12.rar
(18.86 KiB) Downloaded 157 times
Last edited by KaylaKaze on Sun Dec 05, 2010 7:45 pm, edited 3 times in total.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Unit Grouping (with Rotation): SOLVED!

Post by Azhrei »

Cool! I'm looking forward to trying this out. It could solve the (common) problem with mounts and their riders as well as PCs that have animal companions or familiars...

KaylaKaze
Cave Troll
Posts: 57
Joined: Mon Jun 18, 2007 1:08 pm
Contact:

Re: Unit Grouping (with Rotation): SOLVED!

Post by KaylaKaze »

Yep. We'd often have issues in our D&D game where we'd be on a boat or coach and the DM would be trying to move it and turn it and it'd take FOREVER.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Unit Grouping (with Rotation): SOLVED!

Post by wolph42 »

KaylaKaze wrote:Yep. We'd often have issues in our D&D game where we'd be on a boat or coach and the DM would be trying to move it and turn it and it'd take FOREVER.
seconded, had it last WFRP session, 8 chars on a boat, drifting to a bend in the river, terrible. Very curious to how this works!!

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Unit Grouping (with Rotation): SOLVED!

Post by wolph42 »

well, checked it out and did some tests.

First off, works very nice indeed! So again my many thanks.

Stuff I found out at first glance:
1. 'ungrouping' with multiple selected tokens generates an error
2. grouping tokens that were formerly grouped (but not yets ungrouped), makes a mess

I guess, the first is something to work on (and in my experience, shouldn't be too hard to fix), the second, well... if you get the first working properly that should be good enough.

Nonetheless: thanks!!

I'm wondering if this should not be integrated with coveredinswimmaterial's 'Grouping' macro set he created a while ago. The combination of the too would be grant!!

Edit: now this is interesting, the link I added to CIF's topic, is to another tool he created of which I new nothing. I was referring to a 'create custom groups' like in Red Alert (the lib is called 'groupselect'), which I thought CIF made, but I can't find it anymore. This link however points to a work of CIF that is very similar to what you created though differently. Maybe you should discuss this together :wink:

KaylaKaze
Cave Troll
Posts: 57
Joined: Mon Jun 18, 2007 1:08 pm
Contact:

Re: Unit Grouping (with Rotation): SOLVED!

Post by KaylaKaze »

wolph42 wrote:well, checked it out and did some tests.

First off, works very nice indeed! So again my many thanks.

Stuff I found out at first glance:
1. 'ungrouping' with multiple selected tokens generates an error
2. grouping tokens that were formerly grouped (but not yets ungrouped), makes a mess

I guess, the first is something to work on (and in my experience, shouldn't be too hard to fix), the second, well... if you get the first working properly that should be good enough.

Nonetheless: thanks!!

I'm wondering if this should not be integrated with coveredinswimmaterial's 'Grouping' macro set he created a while ago. The combination of the too would be grant!!

Edit: now this is interesting, the link I added to CIF's topic, is to another tool he created of which I new nothing. I was referring to a 'create custom groups' like in Red Alert (the lib is called 'groupselect'), which I thought CIF made, but I can't find it anymore. This link however points to a work of CIF that is very similar to what you created though differently. Maybe you should discuss this together :wink:
1) That's odd. On my test, ungrouping multiples worked fine. Were you trying to ungroup the whole group? Maybe that caused it. (I didn't try that). I should probably add a "Disband" function.

2) Easy enough to fix. That's not something I tested.

This is weird. I just realized instead of using the brackets, I could have just used getSlelectedTokens... I wonder why I didn't do that in the first place...

Edit: Actually, my friend pointed to that the other day while we were playing Warhammer but the lack of free rotation was an issue. That's what inspired me to work on this.

KaylaKaze
Cave Troll
Posts: 57
Joined: Mon Jun 18, 2007 1:08 pm
Contact:

Re: Unit Grouping (with Rotation): SOLVED!

Post by KaylaKaze »

I wasn't able to duplicate the error on removing multiple units. I did do an update though.


Changelog:
v1.1: - No more brackets, just select units for creating group
- Added Disband Group functionality
- Added Readme File

User avatar
booga
Dragon
Posts: 365
Joined: Fri Dec 14, 2007 9:00 am

Re: Unit Grouping (with Rotation): SOLVED!

Post by booga »

Hi,

tested your system with MT 1.3 b76, into new campaign (all default).

-- dragged teh lib token
-- imported the macroset in the campaign window.
-- double-clicked on OnCampaignLoad to define its functions.

dragged a few new tokens, selected them, then hit the Create Group macro, got :

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 error executing expression TL=json.get(getTokensByName("RectDef - Top Left"),0).

I tried different memory configurations to make sure I had enough stack (used, default, 4, 10), to no avail. Also made sure I had the latest Java.

Any idea what could be causing this ?

KaylaKaze
Cave Troll
Posts: 57
Joined: Mon Jun 18, 2007 1:08 pm
Contact:

Re: Unit Grouping (with Rotation): SOLVED!

Post by KaylaKaze »

Yeah. It's still trying to find the bracket tokens from version 1.0. I wonder if it saved properly when I exported the token.

User avatar
booga
Dragon
Posts: 365
Joined: Fri Dec 14, 2007 9:00 am

Re: Unit Grouping (with Rotation): SOLVED!

Post by booga »

Glad it's not me :)

KaylaKaze
Cave Troll
Posts: 57
Joined: Mon Jun 18, 2007 1:08 pm
Contact:

Re: Unit Grouping (with Rotation): SOLVED!

Post by KaylaKaze »

booga wrote:Glad it's not me :)
Fixed it. New version posted. I had accidentally left in some old code.

Thanks for finding the problem and letting me know in such detail that I could solve it easily :)

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Unit Grouping (with Rotation): SOLVED! (Updated 12/5/201

Post by aliasmask »

I may used this some day. Definitely a good idea. Your use of a sin/cos table is a good idea. I was having problems with manually calculating that and MT's limitation with significant digits. For most applications, just having the value for a full degree (not 25.5 degrees) is good enough. I may be able to fix my flanking macro now.

Post Reply

Return to “User Creations”