After messing with this for the last week, I'm on the home stretch but think I'm stuck. I want to set it up so that when my players or monsters attack someone with armour, the armour type plays a factor in how likely a hit is by giving a plus or minus to the to-hit roll (1st Edition AD&D rules). I've got the code set up right now to accept input from the chat window and output the AC factor back into chat. Originally I was thinking of having the AC given to the script, along with the weapon used, then I found the following macro code in another forum post: @{selected|token_name} attacks @{target|token_name} with his @{R1Name}: [[1d20+@{R1Bonus}]] vs [[@{target|ac}]]! This attack does [[@{R1Damage}]] points of damage if it hits! I realized that, with this macro, I could automate a lot of the combat. Unfortunately, I think I've been looking at my code for too long and I can't figure out how to combine the macro with the script, hence this request for assistance. What I would like is to have the macro get the attacker's weapon and the target's AC (possibly using the value in bar 2, as I typically put the AC value), pull the weapon's bonus or penalty from its script object, and add that into the to-hit die roll. It would also be good to pull the damage dice from the weapon object as well, as I included those in the script. However, if someone has a better suggestion for this, I'm open for recommendations. Thanks for any help. My script is below: //dam_sm_min and dam_lg_min = minimum number of dice required for the damage roll //dam_sm_max and dam_lg_max = maximum number of dice required for the damage roll //dam_modifier = the constant value added to the die roll, based on the damage spread //For example, a weapon that does 2-7 points of damage to small or medium opponents // would have a dam_sm_min = 1, a dam_sm_max = 6, and a dam_modifier = 1. on("chat:message", function(msg) { // Exit if not an api command if (msg.type != "api") return; // Get the API Chat Command var command = msg.content.split(" ")[0]; var input = msg.content.split(" ")[1]; var AC_input = msg.content.split(" ")[2]; if (command == "!dam") { var output = ""; function Weapon (dam_sm_min, dam_sm_max, dam_lg_min, dam_lg_max, dam_modifier, AC2, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10){ this.dam_sm_min = dam_sm_min, this.dam_sm_max = dam_sm_max, this.dam_lg_min = dam_lg_min, this.dam_lg_max = dam_lg_max, this.dam_modifier = dam_modifier this.AC2 = AC2, this.AC3 = AC3, this.AC4 = AC4, this.AC5 = AC5, this.AC6 = AC6, this.AC7 = AC7, this.AC8 = AC8, this.AC9 = AC9, this.AC10 = AC10, this.dam_sm = function(){ return (this.dam_sm_min * randomInteger(this.dam_sm_max) + this.dam_modifier) }, this.dam_lg = function(){ return (this.dam_lg_min * randomInteger(this.dam_lg_max) + this.dam_modifier) }, this.no_dam_mod_lg = function(){ return (this.dam_lg_min * randomInteger(this.dam_lg_max)) }, this.no_dam_mod_sm = function(){ return (this.dam_sm_min * randomInteger(this.dam_sm_max)) }; }; //Melee weapons var Battle_Axe = new Weapon (1, 8, 1, 8, 0, -3, -2, -1, -1, 0, 0, 1, 1, 2); var Hand_Axe_melee = new Weapon (1, 6, 1, 4, 0, -3, -2, -1, -1, 0, 0, 1, 1, 2); var Bardiche = new Weapon (2, 4, 3, 4, 0, -2, -1, 0, 0, 1, 1, 2, 2, 3); var Bec_de_Corbin = new Weapon (1, 8, 1, 6, 0, 2, 2, 2, 0, 0, 0, 0, 0, -1); var Bill_Guisarme = new Weapon (2, 4, 1, 10, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0); var Bo_Stick = new Weapon (1, 6, 1, 3, 0, -9, -7, -5, -3, -1, 0, 1, 0, 3); var Club_melee = new Weapon (1, 6, 1, 3, 0, -5, -4, -3, -2, -1, -1, 0, 0, 1); var Dagger_melee = new Weapon (1, 4, 1, 3, 0, -3, -3, -2, -2, 0, 0, 1, 1, 3); var Fauchard = new Weapon (1, 6, 1, 8, 0, -2, -2, -1, -1, 0, 0, 0, -1, -1); var Fauchard_Fork = new Weapon (1, 8, 1, 10, 0, -1, -1, -1, 0, 0, 0, 1, 0, 1); var Fist = new Weapon (1, 3, 1, 2, 0, -7, -5, -3, -1, 0, 0, 2, 0, 4); var Footman_Flail = new Weapon (1, 6, 2, 4, 1, 2, 2, 1, 2, 1, 1, 1, 1, -1); //The footman's flail doesn't require a damage modifier vs. large opponents var Horseman_Flail = new Weapon (1, 4, 1, 4, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0); var Military_Fork = new Weapon (1, 8, 2, 4, 0, -2, -2, -1, 0, 0, 1, 1, 0, 1); var Glaive = new Weapon (1, 6, 1, 10, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0); var Glaive_Guisarme = new Weapon (2, 4, 2, 6, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0); var Guisarme = new Weapon (2, 4, 1, 8, 0, -2, -2, -1, -1, 0, 0, 0, -1, -1); var Guisarme_Voulge = new Weapon (2, 4, 2, 4, 0, -1, -1, 0, 1, 1, 1, 0, 0, 0); var Halberd = new Weapon (1, 10, 2, 6, 0, 1, 1, 1, 2, 2, 2, 1, 1, 0); var Lucern_Hammer = new Weapon (2, 4, 1, 6, 0, 1, 1, 2, 2, 2, 1, 1, 0, 0); var War_Hammer_melee = new Weapon (1, 4, 1, 4, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0); //The war hammer doesn't require a damage modifier vs. large opponents var Jo_Stick = new Weapon (1, 6, 1, 4, 0, -8, -6, -4, -2, -1, 0, 1, 0, 2); var Heavy_Lance = new Weapon (2, 4, 3, 6, 1, 3, 3, 2, 2, 2, 1, 1, 0, 0); //The heavy lance doesn't require a damage modifier vs. large opponents var Medium_Lance = new Weapon (1, 6, 2, 6, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0); //The medium lance doesn't require a damage modifier vs. large opponents var Light_Lance = new Weapon (1, 6, 1, 8, 0, -2, -2, -1, 0, 0, 0, 0, 0, 0); var Footman_Mace = new Weapon (1, 6, 1, 6, 1, 1, 1, 0, 0, 0, 0, 0, 1, -1); //The footman's mace doesn't require a damage modifier vs. large opponents var Horseman_Mace = new Weapon (1, 6, 1, 4, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0); var Morning_Star = new Weapon (2, 4, 1, 6, 1, 0, 1, 1, 1, 1, 1, 1, 2, 2); //The morning star doesn't require a damage modifer vs. small or medium opponents var Partisan = new Weapon (1, 6, 1, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0); //The partisan doesn't require a damage modifer vs. small or medium opponents var Footman_Military_Pick = new Weapon(1, 6, 2, 4, 1, 2, 2, 1, 1, 0, -1, -1, -1, -2); //The footman's pick doesn't require a damage modifier vs. large opponents var Horseman_Military_Pick = new Weapon (1, 4, 1, 4, 1, 1, 1, 1, 1, 0, 0, -1, -1, -1); //The horseman's pick doesn't require a damage modifier vs. large opponents var Awl_Pike = new Weapon (1, 6, 1, 12, 0, -1, 0, 0, 0, 0, 0, 0, -1, -2); var Ranseur = new Weapon (2, 4, 2, 4, 0, -2, -1, -1, 0, 0, 0, 0, 0, 1); var Scimitar = new Weapon (1, 8, 1, 8, 0, -3, -2, -2, -1, 0, 0, 1, 1, 3); var Spear_melee = new Weapon (1, 6, 1, 8, 0, -2, -1, -1, -1, 0, 0, 0, 0, 0); var Spetum = new Weapon (1, 6, 2, 6, 1, -2, -1, 0, 0, 0, 0, 0, 1, 2); //The spetum doesn't require a damage modifier vs. large opponents var Quarter_Staff = new Weapon (1, 6, 1, 6, 0, -7, -5, -3, -1, 0, 0, 1, 1, 1); var Bastard_Sword = new Weapon (2, 4, 2, 8, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0); var Broad_Sword = new Weapon (2, 4, 1, 6, 1, -3, -2, -1, 0, 0, 1, 1, 1, 2); //The broad sword doesn't require a damage modifer vs. small or medium opponents var Long_Sword = new Weapon (1, 8, 1, 12, 0, -2, -1, 0, 0, 0, 0, 0, 1, 2); var Short_Sword = new Weapon (1, 6, 1, 8, 0, -3, -2, -1, 0, 0, 0, 1, 0, 2); var Two_Handed_Sword = new Weapon (1, 10, 3, 6, 0, 2, 2, 2, 2, 3, 3, 3, 1, 0); var Trident = new Weapon (1, 6, 3, 4, 1, -3, -2, -1, -1, 0, 0, 1, 0, 1); //The trident doesn't require a damage modifier vs. large opponents var Voulge = new Weapon (2, 4, 2, 4, 0, -1, -1, 0, 1, 1, 1, 0, 0, 0); //Missile Weapons //Range modifiers are not included var Hand_Axe_thrown = new Weapon (1, 6, 1, 4, 0, -3, -2, -1, -1, 0, 0, 1, 1, 2); var Long_Bow_Composite = new Weapon (1, 6, 1, 6, 0, -2, -1, 0, 0, 1, 2, 2, 3, 3); var Short_Bow_Composite = new Weapon (1, 6, 1, 6, 0, -3, -3, -1, 0, 1, 2, 2, 2, 3); var Long_Bow = new Weapon (1, 6, 1, 6, 0, -1, 0, 0, 1, 2, 3, 3, 3, 3); var Short_Bow = new Weapon (1, 6, 1, 6, 0, -5, -4, -1, 0, 0, 1, 2, 2, 2); var Club_thrown = new Weapon (1, 6, 1, 3, 0, -7, -5, -3, -2, -1, -1, -1, 0, 0); var Heavy_Crossbow = new Weapon (1, 4, 1, 6, 1, -1, 0, 1, 2, 3, 3, 4, 4, 4); var Light_Crossbow = new Weapon (1, 4, 1, 4, 0, -2, -1, 0, 0, 1, 2, 3, 3, 3); var Dagger_thrown = new Weapon (1, 4, 1, 3, 0, -5, -4, -3, -2, -1, -1, 0, 0, 1); var Dart = new Weapon (1, 3, 1, 2, 0, -5, -4, -3, -2, -1, 0, 1, 0, 1); var War_Hammer_thrown = new Weapon (1, 4, 1, 4, 1, -2, -1, 0, 0, 0, 0, 0, 0, 1); //The war hammer doesn't require a damage modifier vs. large opponents var Javelin = new Weapon (1, 6, 1, 6, 0, -5, -4, -3, -2, -1, 0, 1, 0, 1); var Sling_bullet = new Weapon (1, 4, 1, 6, 1, -2, -2, -1, 0, 0, 0, 2, 1, 3); var Sling_stone = new Weapon (1, 4, 1, 4, 0, -5, -4, -2, -1, 0, 0, 2, 1, 3); var Spear_thrown = new Weapon (1, 6, 1, 8, 0, -3, -3, -2, -2, -1, 0, 0, 0, 0); //Test statements //log(Voulge) //log("Voulge damage vs small/med: " + Voulge.dam_sm()) //log("Voulge damage vs large: " + Voulge.dam_lg()) //log("Input =" + input) //log("AC input = " + AC_input) weaponInput = eval(input) //weapon object log(weaponInput) //log("Weapon AC4 value = " + AC_) weapon_AC_adjustment = weaponInput[AC_input] log(weapon_AC_adjustment) //AC_value = tmp.AC2 //log(AC_value) stringCheck = weapon_AC_adjustment.toString() //log(stringCheck) sendChat(msg.who, stringCheck); } });