Modfiy to add advantage/disadvantage

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

User avatar
Xaelvaen
Dragon
Posts: 498
Joined: Wed Aug 31, 2011 9:49 pm
Location: Somewhere between Heaven and Hell

Re: Modfiy to add advantage/disadvantage

Post by Xaelvaen »

I have no clue about the error you're getting, sorry Dorpond =/ I'm not by any means 'pro' like these guys at clean and simple scripts, but I saw your question and had just recently coded that into my 5E framework so thought I'd drop in the same lines I used for my prototype. I usually try to just get it working, then spend weeks cleaning it up with little snippits of code samples I see these guys posting all over the forums XD

I did test this in 1.4.1.7 and it seemed to function just peachy. Hope you get it worked out - with these guys helping, I'm sure you will =)
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

dorpond
RPTools Team
Posts: 5534
Joined: Thu Jun 01, 2006 2:05 pm
Location: Buffalo, NY

Re: Modfiy to add advantage/disadvantage

Post by dorpond »

Xaelvaen wrote:I did test this in 1.4.1.7 and it seemed to function just peachy. Hope you get it worked out - with these guys helping, I'm sure you will =)
I appreciate your help - thank you!

I think your code is a result of coping and pasting from the forums (or something like that), so could you please upload your code in a txt file? I would really like to see how yours works. Thanks!
How to use my bundled artwork (MT1.3B60+): http://forums.rptools.net/viewtopic.php?f=8&t=11759

dorpond
RPTools Team
Posts: 5534
Joined: Thu Jun 01, 2006 2:05 pm
Location: Buffalo, NY

Re: Modfiy to add advantage/disadvantage

Post by dorpond »

SOLUTION: with the help of many up here, we were able to get this working. The solution depends on Bag of Tricks for it to work properly. Thank you guys!

I attached the code below.

I would also love to get Xaelvaen's version working also, which doesn't depend on BoT, if for any reason, just to learn and understand more.

Xaelvaen, could you put your code into a txt file like Aliasmask did, to see if it is the copy paste issue from the forum? Much appreciated!

Code: Select all

<!-- set some basic values -->
[H: saveDC = 0]
[H: tokenList = getSelected()]
[H: statNameList = "STR,DEX,CON,INT,WIS,CHR"]
[H: advantageColorCode = "black,blue,red"]
[H: output = ""]

<!-- get user input -->
[H: abort(input("saveDC|0|Enter Save DC|TEXT",
    "rollAdvantage|No Advantage,Advantage,Disadvantage|Select Advantage|RADIO|ORIENT=H",
    strformat("statName|%{statNameList}|Choose Stat Save|RADIO|VALUE=STRING"),
    "outputType|all,self,gm|Output to Who?|RADIO|SELECT=1 ORIENT=H VALUE=STRING"
))]

<!-- get token data, rolls and saving throw modifier -->
[H, foreach(tokenId,tokenList), code: {
    [H: switchToken(tokenId)]
    
    <!-- get advantage roll -->
    [H: saveRoll = 1d20]
    [H, if(rollAdvantage == 1): saveRoll = max(1d20,saveRoll)]
    [H, if(rollAdvantage == 2): saveRoll = min(1d20,saveRoll)]
    
    <!-- get token stat save roll modifier. note: token name is not case sensitive -->
    [H: statModifier = getProperty(statName+"Save")]
    
    <!-- calc total -->
    [H: rollTotal = statModifier + saveRoll]
    [H: rollColor = listGet(advantageColorCode,rollAdvantage)]
    
    <!-- set state DCFail value. Probably shouldnt do it here, but its easier -->
    [H, if(rollTotal < saveDC): state.DCFail = 1; state.DCFail = 0]
    
    <!-- save output for each token -->
    [H: output = json.append(output,strformat('%{token.name} makes a %{statName} Save and gets a <span title="Roll: %{saveRoll}; Mod: %{statModifier}"><b color="%{rollColor}">%{rollTotal}</b></span>.'))]
}]

<!-- Display Output -->
[H: broadcast(json.toList(output,"<BR>"),eval("bot_"+outputType+"()"))]

<!-- you can remove this line if you make a function of this with hidden output, or you can remove all the comments for final macro -->
[H: abort(0)] 
How to use my bundled artwork (MT1.3B60+): http://forums.rptools.net/viewtopic.php?f=8&t=11759

User avatar
Xaelvaen
Dragon
Posts: 498
Joined: Wed Aug 31, 2011 9:49 pm
Location: Somewhere between Heaven and Hell

Re: Modfiy to add advantage/disadvantage

Post by Xaelvaen »

Their code is highly likely to be superior, but here's the .txt as you've requested. Glad you got it working =D
Attachments
theCode.txt
(2.37 KiB) Downloaded 59 times
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

dorpond
RPTools Team
Posts: 5534
Joined: Thu Jun 01, 2006 2:05 pm
Location: Buffalo, NY

Re: Modfiy to add advantage/disadvantage

Post by dorpond »

That worked like a champ, Xaelvaen, thanks!!

Thanks to all players for helping get through this! Much appreciated!
How to use my bundled artwork (MT1.3B60+): http://forums.rptools.net/viewtopic.php?f=8&t=11759

User avatar
Xaelvaen
Dragon
Posts: 498
Joined: Wed Aug 31, 2011 9:49 pm
Location: Somewhere between Heaven and Hell

Re: Modfiy to add advantage/disadvantage

Post by Xaelvaen »

You're very welcome. How is 5E working out for you? That's pretty much our classic fantasy go-to for tabletop (and Shadowrun Anarchy for anything non-traditional fantasy) - always happy to see others using it =)
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

dorpond
RPTools Team
Posts: 5534
Joined: Thu Jun 01, 2006 2:05 pm
Location: Buffalo, NY

Re: Modfiy to add advantage/disadvantage

Post by dorpond »

Xaelvaen wrote:You're very welcome. How is 5E working out for you? That's pretty much our classic fantasy go-to for tabletop (and Shadowrun Anarchy for anything non-traditional fantasy) - always happy to see others using it =)
I've played all versions of D&D since 3.0 and hands down think 5e is the best of the bunch. :)
How to use my bundled artwork (MT1.3B60+): http://forums.rptools.net/viewtopic.php?f=8&t=11759

User avatar
Xaelvaen
Dragon
Posts: 498
Joined: Wed Aug 31, 2011 9:49 pm
Location: Somewhere between Heaven and Hell

Re: Modfiy to add advantage/disadvantage

Post by Xaelvaen »

Couldn't agree more, though I played 2nd edition as well, and it's still a close favorite. Cheers and happy gaming =)
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

User avatar
StarMan
Dragon
Posts: 939
Joined: Mon Jul 18, 2011 1:10 pm
Location: Toronto

Re: Modfiy to add advantage/disadvantage

Post by StarMan »

Got this working in my 4e (tried 5e once and found it too simplistic; wasn't happy there was no DDI) fw. Go to this page, scroll down to "The MacroPolicebox Group" and watch the last video (named "Toggles"). You can make your output private by using Silent Running Mode and do advantage/disadvantage with d20 Choice Mode.
StarMan - The MacroPolicebox D&D 4E Framework: Import ANYTHING!

Post Reply

Return to “Macros”