PyroMancer2k wrote:knizia.fan wrote:Actually none of my changes made it into b44. I think your problem is that the [c(n): ] feature now starts roll.count at 0 instead of 1. As expected, this will break all sorts of macros. You'll have to modify most of your looping code -- typically you'll need to replace (roll.count-1) with just roll.count now.
Yea the change log is finally up and I figured that was the problem when i saw that. I don't use the (roll.count-1) in most of my loops I just use roll.count so i'll have to chagne it to (roll.count+1)
.
I made the following changes to
knizia.fan's attack macro and added the ThreatRange weapon property and it works fine:
<!-- Build the list of weapon names. --> [h: WpnList = ""] [h, c(9,""): WpnList = WpnList
+ getStrProp(eval("Weapon" + (roll.count+1)), "Name") + ","] <!-- Get the index of the previously selected weapon, if any. --> [h: WpnNum = getStrProp(Private, "DefaultWpn")] [h: WpnNum = if(WpnNum == "", 1, WpnNum)] <!-- Prompt the user for attack options. --> [h: fail = input( "WpnNum | " + WpnList + " | Select weapon to use | LIST | SELECT=" + (WpnNum-1), "CA | 0 | Combat Advantage | CHECK", "MiscAtk | 0 | Misc. attack bonus", "MiscDmg | 0 | Misc. damage bonus" )] [h: abort(fail)] [h: WpnNum = WpnNum + 1] <!-- Save the default weapon for next time. --> [h: Private = setStrProp(Private, "DefaultWpn", WpnNum)] <!-- Set variables from the weapon's property string. -- In this case, the variables are Name, AttackBonus, -- Damage, MaxDamage, Crit, and Keyword. --> [h: varsFromStrProp(eval("Weapon" + WpnNum))] <!-- Print out the results. --><hr> I attack my enemy with {Name}. <br><b>Attack roll:</b> [AtkRoll = 1d20 + AttackBonus + if(CA, 2, 0) + MiscAtk]
{if(AtkRoll>=ThreatRange+AttackBonus+if(CA,2,0)+MiscAtk, ", a critical threat!", "")} {if(AtkRoll== 1+AttackBonus+if(CA,2,0)+MiscAtk, ", a critical miss!", "")} <br><b>Damage roll:</b> [eval(Damage) + MiscDmg] {Keyword} damage.<hr>
I also attempted to adjust the edit weapons macro:
<!-- Build the list of weapon names. --> [h: WpnList = ""] [h, c(9,""): WpnList = WpnList +
getStrProp(eval("Weapon" + (roll.count+1)), "Name") + ","] <!-- Ask the user to select one of the weapons. --> [h: fail = input("WpnNum | " + WpnList + " | Select weapon to edit | LIST")] [h: abort(fail)] <!-- Obtain the property string for the selected weapon. --> [h: WpnNum = WpnNum + 1] [h: WpnName = "Weapon" + WpnNum] [h: WpnProps = eval(WpnName)] <!-- Error checking -- make sure the property string has been set up already. --> [h: NumProps = countStrProp(eval(WpnName))] [h: abort(NumProps)] <!-- Put up a dialog with all the properties in the property string. -- Note that the new property string is automatically assigned back to the -- token property that holds the weapon's property string. --> [h: fail = input("blah | " + WpnNum + " | Weapon number | LABEL", WpnName + " | " + WpnProps + " | Weapon properties | PROPS | setvars=true")] [h: abort(fail)] <!-- Print the new values to the chat window for verification. --> New properties for weapon #{WpnNum}: <table border=0> [h: NumProps = countStrProp(eval(WpnName))] [h,p,c(NumProps,""): "<tr><td style='padding:0px 5px'><b>" + indexKeyStrProp(WpnProps,roll.count-1) + "</b></td><td>" + eval(indexKeyStrProp(WpnProps,roll.count-1)) + "</td></tr>" ] </table>
It seems to work, however I get the following prompt in the chat window:
Could not execute the command: Invalid option: p
Where did I go wrong? Thanks in advance.