Advice please

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

Post Reply
Joviwan
Kobold
Posts: 11
Joined: Tue Mar 24, 2009 9:11 pm

Advice please

Post by Joviwan »

I've been using maptools for a few years now, but I am still pretty noobcakes when it comes to macros. Most of the time I've been able to just brute force or modify macros other people made, but I'm trying to get more complicated with my current macro project, and I'm just not sure how to do what I want.

I'm taking an original macro that is based on a (quite houseruled) Pathfinder campaign, which is a simple two-weapon fighting attack. It currently works as thus:

Code: Select all

[h: result = input("man|ginsus|Action",
"target|guy|Target",
        "mod|2|Modifier",
 "dmod|1|DamageMod",
"wep|Cold Iron Short Sword|Weapon",
"wep2|Mithril Shortsword|Weapon",
"dice|1|Dice",
"sides|6|Sides",
"sides2|6|Sides",
"SPB|Slashing|SPB?",
"threat|19|MinThreat",
"Mult|2|Multiplier")]

[r:getName()] [r:man] [r:target] with her [r:wep]!
<br>
[hit = 1d20+BAB+dex+mod+size-2] to hit, [r:dice]d[r:sides]+[r:dex+dmod]=[t: roll(dice, sides)+dex+dmod] [r:SPB] damage<br>
[if (hit >= threat+BAB+dex+mod+size), code:
{ 
[1d20+BAB+dex+mod+size-2]
to confirm potential critical for
[WHILE(Mult>1), Code:
{
[roll(dice, sides)+dex+dmod]
additional
[r:SPB]
damage
[h:Mult = Mult-1]
}]
};
{
}]

<br>
[r:getName()] [r:man] [r:target] with her [r:wep2]!
<br>
[hit = 1d20+BAB+dex+mod+size-2] to hit, [r:dice]d[r:sides2]+1/2dex+[r:dmod]=[t: roll(dice, sides2)+3+dmod] [r:SPB] damage<br>
[if (hit >= threat+BAB+dex+mod+size), code:
{ 
[1d20+BAB+dex+mod+size-2]
to confirm potential critical for
[WHILE(Mult>1), Code:
{
[roll(dice, sides2)+3+dmod]
additional
[r:SPB]
damage
[h:Mult = Mult-1]
}]
};
{
}]
There are a lot of situational variables and modifiers I would like appended to this with checkboxes, however, with the checkboxes modifying the to hit code and the damage codes accordingly. My results so far have been mixed, and currently I have the following code:

Code: Select all

[h: result = input("man|ginsus|Action",
"target|guy|Target",
        "mod|2|Modifier",
 "dmod|1|DamageMod",
"wep|Cold Iron Short Sword|Weapon",
"wep2|Mithril Shortsword|Weapon",
"dice|1|Dice",
"sides|6|Sides",
"sides2|6|Sides",
"SPB|Slashing|SPB?",
"threat|19|MinThreat",
"Mult|2|Multiplier",
"haste|0|Haste?|check",
"flank|0|Flanking?|check",
"donkey|0|Sneak Attack?|check",
"invis|0|Invisible?|check")]

[h,if(flank == 1): flanking=2, flanking=0]
[h,if(invis == 1): stealth=2, stealth=0]
[h,if(donkey == 1): sneakattack=2d6, sneakattack=0]

[r:getName()] [r:man] [r:target] with her [r:wep]!
<br>
[hit = 1d20+BAB+dex+mod+size-2+haste+flanking+stealth] to hit, [r:dice]d[r:sides]+[r:dex+dmod]+[r:sneakattack]=[t: roll(dice, sides)+dex+dmod+sneakattack] [r:SPB] damage<br>
[if (hit >= threat+BAB+dex+mod+size), code:
{ 
[1d20+BAB+dex+mod+size-2+haste+flanking+stealth]
to confirm potential critical for
[WHILE(Mult>1), Code:
{
[roll(dice, sides)+dex+dmod]
additional
[r:SPB]
damage
[h:Mult = Mult-1]
}]
};
{
}]

<br>
[r:getName()] [r:man] [r:target] with her [r:wep2]!
<br>
[hit = 1d20+BAB+dex+mod+size-2+haste+flanking+stealth] to hit, [r:dice]d[r:sides2]+1/2dex+[r:dmod]+[r:sneakattack]=[t: roll(dice, sides2)+3+dmod+sneakattack] [r:SPB] damage<br>
[if (hit >= threat+BAB+dex+mod+size), code:
{ 
[1d20+BAB+dex+mod+size-2+haste+flanking+stealth]
to confirm potential critical for
[WHILE(Mult>1), Code:
{
[roll(dice, sides2)+3+dmod]
additional
[r:SPB]
damage
[h:Mult = Mult-1]
}]
};
{
}]
What I would like is:
-if Haste is checked, it adds +1 to the attack roll (I would also like it to duplicate the first attack, but that can wait until later)
-if Flanking is checked, it adds +2 to the attack roll.
-if Sneak Attack is checked, I want it to add +2d6 to the damage code (but not be multiplied, obviously)
-if Invisible is checked, I want it to add +2 to the attack roll

Currently it ALMOST works. If I check everything off, it all 'works properly', (except for Sneak Attack, because I don't know how to implement the die rolls properly, currently it just rolls 2d6 and assigns the value to variable sneakattack which then gets added to both attacks, which is not how sneak attack normally works) but if I leave things unchecked, it brings up a prompt for each checkbox asking for a variable, even though I've tried telling it that if the boxes aren't checked, the variable is 0.

Advice or help would be appreciated. Thanks for your time. :)

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: Advice please

Post by Bone White »

[code=php][h,if(flank == 1): flanking=2, flanking=0]
[h,if(invis == 1): stealth=2, stealth=0]
[h,if(donkey == 1): sneakattack=2d6, sneakattack=0] [/code]
Should be[code=php][h,if(flank == 1): flanking=2; flanking=0]
[h,if(invis == 1): stealth=2; stealth=0]
[h,if(donkey == 1): sneakattack=2d6; sneakattack=0] [/code]
You need to use semi colon ";" to separate [if:] results, not a comma ",". This is what was causing your error, it wasn't setting the variables=0 when the checkboxes were not ticked - that's why the prompt.

For the Sneak attack, try:[code=php][h,if(donkey == 1): sneakAttack=roll(2,6); sneakAttack=0] [/code]See Wiki: roll() for information about this new function.

For variable names, a very useful practice is to write them with a lowercase first word, but a capitalised letter for every word thereafter. It makes reading what each variable is used for much easier, both for you and us e.g. thisIsAVariable, thisOneIsForSneakAttacks, sneakAttacks, sneakAttackRoll, totalAttackRoll.

Joviwan
Kobold
Posts: 11
Joined: Tue Mar 24, 2009 9:11 pm

Re: Advice please

Post by Joviwan »

Haha, derp, semi-colons. Thanks! That was really helpful.

With that and some help from a buddy, we got the macro working. That fix didn't make the sneak attack really work correctly--it was still just setting a random static local variable. We eventually bludgeoned a variable+Code out, though, that we glued to the front of every attack roll.

Code: Select all

[h: sneakdice = 2]
.
.
.
[r:getName()] [r:man] [r:target] with her [r:wep]!
<br>
[if(donkey == 1), code: { [h: sneakattack = roll(sneakdice,6)]}; {[ h: sneakattack=0]}]
[hit = 1d20+BAB+dex+mod+size+haste+flanking+stealth] to hit, [r:dice]d[r:sides]+[r:dex+dmod]+[r:sneakattack]=[t: roll(dice, sides)+dex
+dmod+ sneakattack] [r:SPB] damage<br>
[if (hit >= threat+BAB+dex+mod+size+haste+flanking+stealth), code:
{ 
[1d20+BAB+dex+mod+size+haste+flanking+stealth]
to confirm potential critical for
[WHILE(Mult>1), Code:
{
[roll(dice, sides)+dex+dmod]
additional
[r:SPB]
damage
[h:Mult = Mult-1]
}]
};
{
}]

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: Advice please

Post by Bone White »

It may be because you're setting the sneakAttack bonus to sneakAttack, but trying to reference stealth in
threat+BAB+dex+mod+size+haste+flanking+stealth)
Shouldn't it read
threat+BAB+dex+mod+size+haste+flanking+sneakAttack)
instead?

You use this in two different places.

Joviwan
Kobold
Posts: 11
Joined: Tue Mar 24, 2009 9:11 pm

Re: Advice please

Post by Joviwan »

Negative, though this is indeed confusing to anyone who is not specifically me.

invis sets 'stealth' to 2; 2 is the bonus you get to attack rolls vs. opponents against which you count as invisible.

donkey sets sneakAttack to on or off, because donkey is what the wordfilter does to a very abbreviated version of the phrase "assassin's stance," which I was using as shorthand when making the original macro. Assassin's Stance is from 3.5's book of nine swords, which our pathfinder campaign utilizes, and is how this character get's sneak attack.


edit: the place where I use Stealth is in the attack rolls and crit confirmation checks, whereas sneakAttack is in the damage code, in case I obfuscated that.

User avatar
metatheurgist
Dragon
Posts: 364
Joined: Mon Oct 26, 2009 5:51 am

Re: Advice please

Post by metatheurgist »

Code: Select all

[r:dice]d[r:sides]+[r:dex+dmod]+[r:sneakattack]=[t: roll(dice, sides)+dex+dmod+sneakattack] [r:SPB] damage<br>
Curious, you are already aware of the roll() function, so why not try:

Code: Select all

[r:dice]d[r:sides]+[r:dex+dmod]+[r:sneakattack]=[t: roll(dice, sides)+dex+dmod+roll(sneakdice,6)] [r:SPB] damage<br>
or if you prefer to use sneakattack instead of sneakdice:

Code: Select all

[r:dice]d[r:sides]+[r:dex+dmod]+[r:sneakattack]=[t: roll(dice, sides)+dex+dmod+eval(string(sneakattack))] [r:SPB] damage<br>
Untested btw.

Joviwan
Kobold
Posts: 11
Joined: Tue Mar 24, 2009 9:11 pm

Re: Advice please

Post by Joviwan »

We eventually went and did that middle one, it looks like, we just bundled it up with a check-box so it was toggle-able.

Post Reply

Return to “Macros”