Quick Mass-Management/State Modifier

If you have searched the other User Creations subforums and an answer to your question has not been found, please post here!

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
Arcalane
Kobold
Posts: 9
Joined: Tue Sep 29, 2015 4:22 am

Quick Mass-Management/State Modifier

Post by Arcalane »

Long story short I've been bodging together macros for a thing for a while now, but I need something that seems a little out of reach of my own skills.

Simply put; I'd like to, with the aid of a check box, apply various modifiers to all selected tokens at once, without clicking through a dozen input boxes. This is primarily to apply (or remove) the effects of a kind of 'aura of command' on a group of tokens that increases their stats (mostly their attack bonus/modifiers) by a certain amount when they're near a friendly officer/commander.

This could either be a macro on the officer token (grab all NPCs (possibly of the correct faction) within command range, apply or disable buff) or a general global/campaign 'prompt for enable/disable'. At the very least I know it's going to need an if and an input, but the rest eludes me.

I mean, yes, I could bodge this by just using two seperate macros, but my macro panels are overflowing as-is.

A similar setup for applying one or more values to many tokens at once using one or more dropdowns/inputs/etc. would also be very useful. Like I said, panels are overflowing and could do with some housekeeping/condensing.

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

Re: Quick Mass-Management/State Modifier

Post by wolph42 »

seems doable (everything you mention). When you say 'faction' is that delimited by name, state or something else?
Anyway, you would need: Wiki: getTokenNames() here you can set range and state for filters and it results in a list of token names through which you can loop and set or unset anything you like.

Arcalane
Kobold
Posts: 9
Joined: Tue Sep 29, 2015 4:22 am

Re: Quick Mass-Management/State Modifier

Post by Arcalane »

It could be either, to be honest - they all have an identifying string in the token name (e.g. "Republic Soldier", where Republic is the faction), but it could just as easily be changed to an iconless/invisible status.

I did take a brief crack at using either getTokenNames or getTokens, but the exact formatting of the json eluded me and I didn't save my changes, so whatever half-baked code I was working with has since vanished into the mists of time. Not a huge surprise or significant loss, seeing as it wasn't working to begin with.

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

Re: Quick Mass-Management/State Modifier

Post by wolph42 »

you could have posted it here and ask us to have a look at it. Anyway, if I copy paste the given example from the wiki:

Code: Select all

[h: cond = json.set("{}", "range", json.set("{}", "upto", 1, "distancePerCell", 0, "metric", "NO_DIAGONALS"), "npc", 1, "unsetStates", json.append("[]","Dead"))] 
and change it lets say, range 10, state 'republic' you get.

Code: Select all

[h: cond = json.set("{}", "range", json.set("{}", "upto", 10, "distancePerCell", 0, "metric", "NO_DIAGONALS"), "npc", 1, "setStates", json.append("[]","republic"))]
[h: names = getTokenNames("json", cond)] 
If the result is too daunting you can also do

Code: Select all

[h: names = getTokenNames(",", cond)] 
but this has the drawback of names with special characters like "," in them. You omit this mostly by using json.

Arcalane
Kobold
Posts: 9
Joined: Tue Sep 29, 2015 4:22 am

Re: Quick Mass-Management/State Modifier

Post by Arcalane »

Kinda hard when I closed it well over six hours ago! It may just have been that I wasn't running it as a trusted macro at the time, I was half-asleep.

Moving on - okay, so that's a start, but I'm not quite seeing how to go from there to hooking up the input and then passing the modifiers/etc. on to the tokens that the names output returns. Bear with me here, I don't always do too well with tutorials and explanations; my usual process is 'take something I know works, then modify it until it does what I want'.

Ideally the process is this;

1. Use macro on officer token.
2. Prompt appears with checkbox (and/or listbox/input field/radio buttons/whathaveyou) to enable/disable/modify various values.
3. Hit 'OK', modifies appropriate values on all the soldier/selected tokens at once using the values provided for the input.

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

Re: Quick Mass-Management/State Modifier

Post by wolph42 »

'take something I know works, then modify it until it does what I want'
thats about exactly what i did in my former post :wink: And let me keep doing that below :mrgreen:
1. Use macro on officer token.
2. Prompt appears with checkbox (and/or listbox/input field/radio buttons/whathaveyou) to enable/disable/modify various values.
3. Hit 'OK', modifies appropriate values on all the soldier/selected tokens at once using the values provided for the input.
1. well...thats clicking a button, nothing special there
2. you need Wiki: input()

here again a copy paste from the wiki:

Code: Select all

[h:status=input(
    "junkVar|"+powerClicked+"|Selected Power|LABEL",
    "ComAdv|0|Combat Advantage|CHECK",
    "MarkPenalty|0|Marked by an enemy other than your target|CHECK",
    "TargetConcealed|0|Target has Concealment|CHECK",
    "MiscBonus|0|Miscellaneous BONUSES to your attack roll",
    "MiscPenalty|0|Miscellaneous PENALTIES to your attack roll",
    "mdb|0|Miscellaneous BONUS to Damage")]
[h:abort(status)] 
modify

Code: Select all

[h:abort(input(
    "junkVar|"+names+"|Selected Tokens|LABEL",
    "ComAdv|0|Set the special state?|CHECK"
))]
<!-- note that 'names' in there only works with the "," delimiter in getTokenNames, not with the "json" delimiter -->
 
3. the trickier part, loop through all 'names' and set the state. For this you need [foreach:]
again, grab example:

Code: Select all

[FOREACH (enemy, enemyList, "<br>"): "You really hate " + enemy] 
adapt:

Code: Select all

[FOREACH (name, names): setState("Special State", 1, name)] 

Arcalane
Kobold
Posts: 9
Joined: Tue Sep 29, 2015 4:22 am

Re: Quick Mass-Management/State Modifier

Post by Arcalane »

I figured a foreach might come into things somewhere - I assume it's possible to nest that within an if/switch or vice-versa? e.g.

Code: Select all

[if(ComAdv == 1), CODE: {
[foreach(blah) that enables the thing]
};{
[foreach(blah) that disables the thing]
}]
Excusing the pseudocode/shorthand, of course. ;)

I've used input() to great effect before for my 3.5 and pathfinder attack macros, so I know plenty well how that works at least, and I've also made use of if() and switch() a fair amount as well for various purposes.

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

Re: Quick Mass-Management/State Modifier

Post by wolph42 »

Arcalane wrote:I figured a foreach might come into things somewhere - I assume it's possible to nest that within an if/switch or vice-versa? e.g.

Code: Select all

[if(ComAdv == 1), CODE: {
[foreach(blah) that enables the thing]
};{
[foreach(blah) that disables the thing]
}]
yeah that would work. A bit smarter would be:

Code: Select all

[FOREACH (name, names): setState("Special State", ComAdv, name)]  

Arcalane
Kobold
Posts: 9
Joined: Tue Sep 29, 2015 4:22 am

Re: Quick Mass-Management/State Modifier

Post by Arcalane »

That works. I am however still getting code output in the chat window, which obviously isn't ideal if this is something I need to disable in combat because the officer bought the farm, and I'm not seeing how to easily turn that off...

I have at least figured out how to use getProperty in combination with name from the list output in order to provide an armour/health/etc. bonus to all the goons in the aura at least, so that's another milestone down.

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

Re: Quick Mass-Management/State Modifier

Post by wolph42 »

there are many ways to suppress output. The 'final' (best) method would be making it a Wiki: defineFunction() and simply set the 'ignore output' flag to 1. and then call the defined function instead.

other simpler ways are simply putting a
h: or h, option in front of the code. So
[h:abort(input(....))]
or
[h,foreach:()]
check the 'READ THIS' link in my sig for better instructions on the , and :

Arcalane
Kobold
Posts: 9
Joined: Tue Sep 29, 2015 4:22 am

Re: Quick Mass-Management/State Modifier

Post by Arcalane »

I figured it would be something like that - I tried h: but forgot h, was a thing.

I think I can get things going along from here at least, with a little more tweaking. Thanks for the help.

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

Re: Quick Mass-Management/State Modifier

Post by wolph42 »

Arcalane wrote:I figured it would be something like that - I tried h: but forgot h, was a thing.

I think I can get things going along from here at least, with a little more tweaking. Thanks for the help.
ok, good luck. Don't forget to read the 'READ THIS' article!!

Post Reply

Return to “Requests for HELLLLP!”