Is it possible to continuously track average party level?

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
Chimera245
Cave Troll
Posts: 29
Joined: Thu Oct 09, 2014 6:39 pm

Is it possible to continuously track average party level?

Post by Chimera245 »

And what I mean is, Can macros/token properties/library tokens/whatever be set up in such a way that whatever the levels of the PCs, Maptool auto-calculates the average party level without any direct input?

Like I know that some token properties can be derived from other token properties, like anything based out of D&D/Pathfinder will usually have characters written up like "Strength--15, StrBonus--[r:floor((Strength/2)-5)]" so that whenever Strength is changed, it's corresponding bonus is adjusted, too.

But I'm not sure if it's possible to do this with multiple tokens being referenced at once...

What I'm trying to do is set up a macro that will randomly generate an NPC, like choose a random race, class, ability scores, etc. and apply it all to the selected token's token properties. But I want it to generate the NPC's level based on the party level. I'd really rather not have to edit the macro whenever the PCs gain a level, or be asked to input a number each time I click the button.

So is it possible to have a derived "party level" stat somehow, that I can use in the macro's calculation?

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

Re: Is it possible to continuously track average party level

Post by wolph42 »

sure it is, however there are some circumstances that are of influence, for one how doe the macro 'know' which tokens represent the party, e.g. all PCs are member of the party? another thing is when tokens of players are on another map, its not very simple to determine it then.

and easy solution might be if you keep track of the level of the pcs in a property on a lib token. This property vcan be accessed from every map. And you only need to change it when a party member changes its level (through a macro) simply update the player token AND update the value on the lib property.
Then when you need it just retrieve the stored values and calculate the average.

Chimera245
Cave Troll
Posts: 29
Joined: Thu Oct 09, 2014 6:39 pm

Re: Is it possible to continuously track average party level

Post by Chimera245 »

That's another thing I was wondering, How to designate PC vs NPC status. (as far as I can tell, the PC/NPC dropdown menu next to token name is purely cosmetic, and macros can't interact with it...)

I wanted to have the system still be automated, regardless of how many players show up each session or whether anyone dies/retires and switches characters.

Is there no way to grab a token's properties on another token? Because I can see this being useful for more than just tracking party level, such as familiars/animal companions that auto-level when their owner does...

I know I can do things like "HP:[r:(HitDice+CON)*Level]" on a token when to reference its own properties. But is there anything that stops me from doing things like "FamiliarHP:[r:ThatCommandThatLooksUpTokenProperties(WizardCharacter(HP))/2]" other than ignorance?

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

Re: Is it possible to continuously track average party level

Post by wolph42 »

Chimera245 wrote:That's another thing I was wondering, How to designate PC vs NPC status. (as far as I can tell, the PC/NPC dropdown menu next to token name is purely cosmetic, and macros can't interact with it...)
Wiki: isPC()
Wiki: isNPC()
I wanted to have the system still be automated, regardless of how many players show up each session or whether anyone dies/retires and switches characters.
you're not answering my question, which in case it was not clear is: "how does the macro *know* which tokens to choose to calculate the level?"
Is there no way to grab a token's properties on another token? Because I can see this being useful for more than just tracking party level, such as familiars/animal companions that auto-level when their owner does...
There are at least two ways:
you can use Wiki: switchToken() to 'switch' to the other tokens property set or you can use Wiki: getProperty() to remotely access the token in question.
I know I can do things like "HP:[r:(HitDice+CON)*Level]" on a token when to reference its own properties. But is there anything that stops me from doing things like "FamiliarHP:[r:ThatCommandThatLooksUpTokenProperties(WizardCharacter(HP))/2]" other than ignorance?
FamiliarHP:[r:getProperty("HP", "WizardCharacter")/2]

*That* is really tricky though, cause if 'WizardCharacter' is NOT on the same map, stuff goes haywire!

Chimera245
Cave Troll
Posts: 29
Joined: Thu Oct 09, 2014 6:39 pm

Re: Is it possible to continuously track average party level

Post by Chimera245 »

you're not answering my question, which in case it was not clear is: "how does the macro *know* which tokens to choose to calculate the level?"
Sorry, I thought you were asking me sort of rhetorically, as part of your explanation. The fact that that is also one of MY questions didn't help...

In an ideal world, I want to have PCs on the map, sometimes they get enough XP to level up, sometimes everyone shows up, sometimes not, sometimes an NPC joins for a while as a DMPC to guide them or be escorted, I pull out a new npc token, run the "generate random stats" macro, and suddenly I have a new token whose level is in the appropriate range to fight the party.

Basically, I want my macro to say [h:level=("average party level" property on lib:token)+(some small variance, like +/-one or two levels)]

The lib:token will have a property that reads "AvgLevel:[r:(getProperty("Level","FirstPC")+getProperty("Level","SecondPC")+(AndSoOn))/NumberOfPCs]" and possibly also "PCcount:[r:someAwesomeCommandThatTalliesUpTheNumberOfTokensWithThePCTag]" to make the math work in the first property.

Or in short, I want this macro to reference "All tokens whose tag is set to PC at any given time".

Without knowing the amount of PCs and their token names ahead of time, and mandating that they all stay on the same map at the same time, I don't think this is doable...

Though I suppose I could fudge it a bit, and have it be MOSTLY right by having it only reference the party LEADER's level... That way I'd only ever have to manually change anything if the leader changed.
FamiliarHP:[r:getProperty("HP", "WizardCharacter")/2]

*That* is really tricky though, cause if 'WizardCharacter' is NOT on the same map, stuff goes haywire!
THAT'S good to know. I had assumed that it would fail because token properties might not count as "trusted macros" or something... If that works, then I can definitely get my "only use party leader" Plan B to work.

On a tangent, could you describe what kind of haywire-ness this could lead to? Like would this result in Maptool crashing, and losing all campaign progress since the last auto-save, or would this just result in a familiar with an HP value of "potato"?

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

Re: Is it possible to continuously track average party level

Post by wolph42 »

the haywireness can vary. If its just a property and it won't show up on the stat sheet then a mere error in the chat. If however it *would* show up in the statsheet as e.g.
"*Wounds: 15" would show up then it would produce roughly 50 pop-up errors per second you hover over the token on screen.

What I would suggest you do:
1. make sure the ONLY pc tokens on the map are players tokens
2. use Wiki: getTokenNames()
3. cycle through them while retrieving the level
4. average them
5. done.

it would *roughly* look like this

Code: Select all

toks = getTokenNames(",", json.set("{}", "pc", 1))
nToks = listCount(toks)
totLevel = 0
foreach(tok, toks): totLevel = totLevel + getProperty("Level", tok)
avgLevel = totLevel/nToks

Chimera245
Cave Troll
Posts: 29
Joined: Thu Oct 09, 2014 6:39 pm

Re: Is it possible to continuously track average party level

Post by Chimera245 »

the haywireness can vary. If its just a property and it won't show up on the stat sheet then a mere error in the chat. If however it *would* show up in the statsheet as e.g.
"*Wounds: 15" would show up then it would produce roughly 50 pop-up errors per second you hover over the token on screen.
What if the stat is not on the stat sheet, but is derived into another stat that is?

such as:
FamiliarHP:[r:getProperty(HP, WizardCharacter)/2]
*Health:[r:FamiliarHP+"/"+FamiliarMaxHP]

Would that change anything? I'm assuming no, because Maptool is still trying to show me math that it can't do, but I figured I'd ask anyway.
toks = getTokenNames(",", json.set("{}", "pc", 1))
nToks = listCount(toks)
totLevel = 0
foreach(tok, toks): totLevel = totLevel + getProperty("Level", tok)
avgLevel = totLevel/nToks
I will probably copy/paste this into Notepad, and save it for future reference when I have a deeper understanding of Maptool code, and use my leader-only backup plan until then...
Especially since I see a reference to json in there. One of these days I will begin dipping my toes into the world of Java, but for now, I just wanna play a game. (And when I finally DO start learning Java, I will probably put that knowledge to use modding Minecraft instead...)

Speaking of my leader-only backup plan...

It stopped working. I was originally using the leader's name directly in the macro, for testing purposes, then I tried to set up a Library token to be a middleman between the two, so that I could macro in other token names as needed, but now I get an error.

my NPC randomizing macro used to start with:

[h:Level=getProperty("LV","LeaderName")-4+1d7]

which worked fine.

now it reads:

[h:Level=getLibProperty("PartyLevel","Lib:Game")-4+1d7]

where a Library Token with a property reading:

PartyLevel:[r:getProperty("LV", "Leadername"))]

(And I manually typed that in, as I know getLibProperty returns nothing when using default values)

Now I click the macro and get "Error in body of roll.       Statement options (if any): h       Statement Body : Level=getLibProperty("PartyLevel","Lib:Game")-4+1d7" in chat...

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

Re: Is it possible to continuously track average party level

Post by wolph42 »

1. same haywiredness (because of the reason you figured out yourself)
2. you have two closing )) in your code hence the error (or at least one cause for an error)

User avatar
jay
RPTools Team
Posts: 1767
Joined: Tue Feb 07, 2006 1:07 am
Location: Austin, Tx

Re: Is it possible to continuously track average party level

Post by jay »

Since this isn't really a character tool thread, you might want to move it to map tool. I'm just saying :-)

Chimera245
Cave Troll
Posts: 29
Joined: Thu Oct 09, 2014 6:39 pm

Re: Is it possible to continuously track average party level

Post by Chimera245 »

Since this isn't really a character tool thread, you might want to move it to map tool. I'm just saying :-)
I thought I DID post it in Maptool... I'm confused...
2. you have two closing )) in your code hence the error (or at least one cause for an error)
It's ALWAYS a punctuation thing... You'd think after all this time, I'd go check my spelling first, instead of spending an hour looking up macro functions on the wiki, and/or finding other ways of expressing the same basic function, or otherwise doubting my own understanding of the code...

Post Reply

Return to “MapTool”