Skip to content

Instantly share code, notes, and snippets.

@crystalattice
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save crystalattice/4d5817236574885acc30 to your computer and use it in GitHub Desktop.

Select an option

Save crystalattice/4d5817236574885acc30 to your computer and use it in GitHub Desktop.
Weapon vs AC to-hit modifiers
//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 == "!ac") {
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))
};
};
var weaponLookup = {
//Melee weapons
"Battle_Axe": new Weapon (1, 8, 1, 8, 0, -3, -2, -1, -1, 0, 0, 1, 1, 2),
"Hand_Axe_melee": new Weapon (1, 6, 1, 4, 0, -3, -2, -1, -1, 0, 0, 1, 1, 2),
"Bardiche": new Weapon (2, 4, 3, 4, 0, -2, -1, 0, 0, 1, 1, 2, 2, 3),
"Bec_de_Corbin": new Weapon (1, 8, 1, 6, 0, 2, 2, 2, 0, 0, 0, 0, 0, -1),
"Bill_Guisarme": new Weapon (2, 4, 1, 10, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0),
"Bo_Stick": new Weapon (1, 6, 1, 3, 0, -9, -7, -5, -3, -1, 0, 1, 0, 3),
"Club_melee": new Weapon (1, 6, 1, 3, 0, -5, -4, -3, -2, -1, -1, 0, 0, 1),
"Dagger_melee": new Weapon (1, 4, 1, 3, 0, -3, -3, -2, -2, 0, 0, 1, 1, 3),
"Fauchard": new Weapon (1, 6, 1, 8, 0, -2, -2, -1, -1, 0, 0, 0, -1, -1),
"Fauchard_Fork": new Weapon (1, 8, 1, 10, 0, -1, -1, -1, 0, 0, 0, 1, 0, 1),
"Fist": new Weapon (1, 3, 1, 2, 0, -7, -5, -3, -1, 0, 0, 2, 0, 4),
"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
"Horseman_Flail": new Weapon (1, 4, 1, 4, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0),
"Military_Fork": new Weapon (1, 8, 2, 4, 0, -2, -2, -1, 0, 0, 1, 1, 0, 1),
"Glaive": new Weapon (1, 6, 1, 10, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0),
"Glaive_Guisarme": new Weapon (2, 4, 2, 6, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0),
"Guisarme": new Weapon (2, 4, 1, 8, 0, -2, -2, -1, -1, 0, 0, 0, -1, -1),
"Guisarme_Voulge": new Weapon (2, 4, 2, 4, 0, -1, -1, 0, 1, 1, 1, 0, 0, 0),
"Halberd": new Weapon (1, 10, 2, 6, 0, 1, 1, 1, 2, 2, 2, 1, 1, 0),
"Lucern_Hammer": new Weapon (2, 4, 1, 6, 0, 1, 1, 2, 2, 2, 1, 1, 0, 0),
"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
"Jo_Stick": new Weapon (1, 6, 1, 4, 0, -8, -6, -4, -2, -1, 0, 1, 0, 2),
"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
"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
"Light_Lance": new Weapon (1, 6, 1, 8, 0, -2, -2, -1, 0, 0, 0, 0, 0, 0),
"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
"Horseman_Mace": new Weapon (1, 6, 1, 4, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0),
"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
"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
"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
"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
"Awl_Pike": new Weapon (1, 6, 1, 12, 0, -1, 0, 0, 0, 0, 0, 0, -1, -2),
"Ranseur": new Weapon (2, 4, 2, 4, 0, -2, -1, -1, 0, 0, 0, 0, 0, 1),
"Scimitar": new Weapon (1, 8, 1, 8, 0, -3, -2, -2, -1, 0, 0, 1, 1, 3),
"Spear_melee": new Weapon (1, 6, 1, 8, 0, -2, -1, -1, -1, 0, 0, 0, 0, 0),
"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
"Quarter_Staff": new Weapon (1, 6, 1, 6, 0, -7, -5, -3, -1, 0, 0, 1, 1, 1),
"Bastard_Sword": new Weapon (2, 4, 2, 8, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0),
"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
"Long_Sword": new Weapon (1, 8, 1, 12, 0, -2, -1, 0, 0, 0, 0, 0, 1, 2),
"Short_Sword": new Weapon (1, 6, 1, 8, 0, -3, -2, -1, 0, 0, 0, 1, 0, 2),
"Two_Handed_Sword": new Weapon (1, 10, 3, 6, 0, 2, 2, 2, 2, 3, 3, 3, 1, 0),
"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
"Voulge": new Weapon (2, 4, 2, 4, 0, -1, -1, 0, 1, 1, 1, 0, 0, 0),
//Missile Weapons
//Range modifiers are not included
"Hand_Axe_thrown": new Weapon (1, 6, 1, 4, 0, -3, -2, -1, -1, 0, 0, 1, 1, 2),
"Long_Bow_Composite": new Weapon (1, 6, 1, 6, 0, -2, -1, 0, 0, 1, 2, 2, 3, 3),
"Short_Bow_Composite": new Weapon (1, 6, 1, 6, 0, -3, -3, -1, 0, 1, 2, 2, 2, 3),
"Long_Bow": new Weapon (1, 6, 1, 6, 0, -1, 0, 0, 1, 2, 3, 3, 3, 3),
"Short_Bow": new Weapon (1, 6, 1, 6, 0, -5, -4, -1, 0, 0, 1, 2, 2, 2),
"Club_thrown": new Weapon (1, 6, 1, 3, 0, -7, -5, -3, -2, -1, -1, -1, 0, 0),
"Heavy_Crossbow": new Weapon (1, 4, 1, 6, 1, -1, 0, 1, 2, 3, 3, 4, 4, 4),
"Light_Crossbow": new Weapon (1, 4, 1, 4, 0, -2, -1, 0, 0, 1, 2, 3, 3, 3),
"Dagger_thrown": new Weapon (1, 4, 1, 3, 0, -5, -4, -3, -2, -1, -1, 0, 0, 1),
"Dart": new Weapon (1, 3, 1, 2, 0, -5, -4, -3, -2, -1, 0, 1, 0, 1),
"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
"Javelin": new Weapon (1, 6, 1, 6, 0, -5, -4, -3, -2, -1, 0, 1, 0, 1),
"Sling_bullet": new Weapon (1, 4, 1, 6, 1, -2, -2, -1, 0, 0, 0, 2, 1, 3),
"Sling_stone": new Weapon (1, 4, 1, 4, 0, -5, -4, -2, -1, 0, 0, 2, 1, 3),
"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)
var parts = msg.content.split(' ');
var command = parts.shift();
var AC_input = parts.pop();
var input = parts.join(' '); // `input` will be everything except the first and last element of `parts`
var weaponInput = weaponLookup[input];
sendChat(msg.who, weaponInput);
///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);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment